PAT1022D进制的A+B (20)

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

long A,B,D,APB;
stack<long> myStack;
void transform()
{
	if(APB==0)
	{
		cout<<0;
		return;
	}


	while(APB!=0)
	{
		myStack.push(APB%D);
		APB/=D;
	}

	while(!myStack.empty())
	{
		cout<<myStack.top();
		myStack.pop();
	}
	
	
}


int main()
{

	cin>>A>>B>>D;
	APB=A+B;
	transform();
}

你可能感兴趣的:(PAT1022D进制的A+B (20))