题目如下:
我主要使用的知识点是STL里面的栈,它有先进后出的特点,这个特点有助于我们进制转换。
如有想学STL,可以看我的:STL知识总结https://blog.csdn.net/m0_67500944/article/details/126904238?spm=1001.2014.3001.5502
代码如下:
#include<iostream>
#include<stack>
using namespace std;
int main(){
int n,m;
stack<int> s;
for(int i = 0;i < 3;i ++){
cin>>n;
while(n>8){
m=n%8;
s.push(m);
n=n/8;
}
s.push(n);
while(!s.empty()){
cout<<s.top();
s.pop();
}
cout<<endl;
}
return 0;
}
到此结束咯。