栈实现十进制转八进制

来源:互联网 发布:matlab python 编辑:程序博客网 时间:2024/05/22 14:18
#include <iostream>
#include <stack>
using namespace std;
 
 
int main()
{
    int num;
    const int mode=8;
    cin>>num;
    stack<int>st;
 
    while(num)
    {
        st.push(num%mode);
        num=num/mode;
    }
    while(!st.empty())
    {
        cout<<st.top();
        st.pop();
    }
    system("pause");
}
1 0