您的位置:首页 > 其它

1022. D进制的A+B (20)

2018-03-05 07:42 330 查看
使用unsigned int来做,并使用stack来保存每一位的数#include<iostream>
#include<stack>
using namespace std;
int main()
{
unsigned int A,B,D,sum;
stack<int> s;
//freopen("1022.txt","r",stdin);
cin>>A>>B>>D;
sum=A+B;
do{
s.push(sum%D);
sum/=D;
} while(sum);
while(!s.empty())
{
cout<<s.top();
s.pop();
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: