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;
}
#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)
- 1022. D进制的A+B (20)
- PAT (Basic Level) Practise (中文)- 1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- B1022. D进制的A+B (20)
- Pat 1022. D进制的A+B (20)
- PAT(B) 1022. D进制的A+B (20)
- Basic Level 1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- PAT (Basic Level) Practise (中文) 1022. D进制的A+B (20)
- pat乙级1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- PAT乙级1017. A除以B (20)&&1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- PAT1022 D进制的A+B (20)
- 1022. D进制的A+B (20)
- 1022. D进制的A+B (20)
- 1022. D进制的A+B (20)