八進制數

網址:http://zju.acmclub.com/index.php?app=problem_title&id=1&problem_id=1330

#include<iostream>
#include<stack>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int m;
        stack<int> s;
        while(n > 0)
        {
            m = n % 8;
            n = n / 8;
            s.push(m);
        }
        while(!s.empty())
        {
            printf("%d",s.top());
            s.pop();
        }
        printf("\n");
    }
    return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章