#include <iostream>
#include<stack>
using namespace std;

int main()
{
	stack<int> s;
	int n = 100;
	int r = 8; // r进制
	
	while(n)//范式
	{
		s.push(n % r);
		n /= r;
	}

	while(!s.empty())  //stack没有遍历器
	{
		cout << s.top();
		s.pop(); //s.pop()并不返回栈顶元素
	}

	cout << endl;

	return 0;
}


本文转载:CSDN博客