PAT(甲级)1001. A+B Format (20)
2017-01-22 14:36
453 查看
题目:https://www.patest.cn/contests/pat-a-practise/1001
代码:#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
int a,b,sum,i,length=0;
int ans[12];
scanf("%d%d",&a,&b);
sum=a+b;
if(sum<0){
printf("-");
sum=-sum;
}
do{
ans[length++]=(sum%10);
sum=sum/10;
}while(sum!=0);
for(i=length-1;i>=0;i--){
printf("%d",ans[i]);
if(i%3==0&&i>0)
printf(",");
}
system("pause");
}
代码:#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
int a,b,sum,i,length=0;
int ans[12];
scanf("%d%d",&a,&b);
sum=a+b;
if(sum<0){
printf("-");
sum=-sum;
}
do{
ans[length++]=(sum%10);
sum=sum/10;
}while(sum!=0);
for(i=length-1;i>=0;i--){
printf("%d",ans[i]);
if(i%3==0&&i>0)
printf(",");
}
system("pause");
}
相关文章推荐
- PAT甲级1001. A+B Format (20)
- [PAT甲级]1001. A+B Format (20)(AB和的标准输出)
- PAT 甲级1001. A+B Format (20)
- PAT甲级 1001. A+B Format (20)
- PAT甲级 1001. A+B Format (20)
- PAT甲级 1001. A+B Format (20) 题目翻译与答案
- PAT甲级1001. A+B Format (20)
- PAT甲级1001. A+B Format (20)解题报告
- pat甲级1001. A+B Format (20)
- 1001. A+B Format (20)-PAT甲级刷题
- PAT甲级-1001. A+B Format (20)逗号分隔
- PAT甲级 1001. A+B Format (20)--两种方法
- PAT甲级1001. A+B Format (20)
- PAT甲级.1001. A+B Format (20)
- PAT甲级1001. A+B Format(20)
- PAT甲级1001. A+B Format (20)
- 1001. A+B Format (20)-PAT甲级真题
- 【PAT甲级】1001. A+B Format (20)
- PAT甲级-1001. A+B Format (20)
- 浙江大学PAT_甲级_1001. A+B Format (20)