八进制

题目链接:https://www.nowcoder.com/practice/eda051c1effc4dffa630bc8507f0c5f7?tpId=40&tqId=21562&tPage=1&rp=1&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking

题目描述

输入一个整数,将其转换成八进制数输出。

输入描述:

输入包括一个整数N(0<=N<=100000)。

输出描述:

可能有多组测试数据,对于每组数据,
输出N的八进制表示数。
示例1

输入

7
8
9

输出

7
10
11

 1 #include <iostream>
 2 #include <string>
 3 #include <cstring>
 4 #include <algorithm>
 5 #include <cmath>
 6 #include <stack>
 7 using namespace std;
 8 int main()
 9 {
10     int n;
11     stack<int> s;
12     while(cin>>n){
13         while(n){
14             s.push(n%8);
15             n/=8;
16         }
17         while(s.size()){
18             cout<<s.top();
19             s.pop();
20         }
21         cout<<endl;
22     }
23     return 0;
24 }
原文地址:https://www.cnblogs.com/shixinzei/p/8072059.html