1022. D进制的A+B (20)
2018-03-05 19:16
295 查看
使用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;
}
#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;
}
相关文章推荐
- 1022. D进制的A+B (20)
- Basic Level 1022. D进制的A+B (20)
- 1022. D进制的A+B (20) PAT乙级
- Programming Ability Test学习 1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- 1022. D进制的A+B (20) PAT
- 1022. D进制的A+B (20)
- PATB1022. D进制的A+B(20)
- PAT-乙级-1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- PAT 乙级 1022 D进制的A+B (20)
- 1022. D进制的A+B (20)
- PAT 乙级 1022.D进制的A+B(20)
- 1022. D进制的A+B (20)
- PAT乙级—1022. D进制的A+B (20)-native
- PAT乙级1022. D进制的A + B(20)
- 【PAT】(乙级)1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- PAT乙级1022. D进制的A+B (20)
- PAT乙级真题及训练集(16)--1022. D进制的A+B (20)