数据结构 严蔚敏 P48
#include<iostream> #include<string> #include<stack> using namespace std; string conversion(int num){ stack<int> intstack; int temp; string str,strtemp; while (num){ intstack.push(num % 8); num = num / 8; } while (!intstack.empty()){ temp = intstack.top(); intstack.pop(); strtemp = to_string(temp); str += strtemp; } return str; } int main() { string s; s = conversion(1348); cout << s << endl; }