PAT 1001. A+B Format
2013-12-31 11:45
134 查看
#include <iostream> #include<stdio.h> #include<stdlib.h> using namespace std; long a=0; long b=0; long c=0; int sum[10]; int ind=0; int flg=false; int main() { scanf("%lld %lld",&a,&b); c=a+b; if(c<0) { c=-c; flg=true; } //cout<<c<<endl; while(c!=0) { sum[ind++]=c%10; c=c/10; } // for(int i=0;i<ind;i++) cout<<sum[i]; // cout<<endl; if(flg) printf("-"); // cout<<ind<<endl; printf("%d",sum[ind-1]); for(int i=ind-2;i>=0;i--) { if((i+1)%3==0) { printf(",%d",sum[i]); } else { printf("%d",sum[i]); } } return 0; }
相关文章推荐
- PAT(甲级)1001. A+B Format (20)
- PAT 1001. A+B Format (20)
- PAT1001.A+B Format
- PAT (Advanced Level) Practise 1001. A+B Format (20)
- 【PAT甲级】【C】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 (Advanced Level) Practise 1001. A+B Format (20)
- PAT-PAT (Advanced Level) Practise 1001. A+B Format (20) 【二星级】
- pat 1001. A+B Format
- PAT(Advanced Level)1001. A+B Format (20)
- PAT:1001. A+B Format (20)
- PAT 1001. A+B Format (20)
- 浙江大学PAT_甲级_1001. A+B Format (20)
- 浙大 PAT Advanced level 1001. A+B Format
- PAT 1001 A+B Format (20)
- PAT---1001. A+B Format(调试过程)
- PAT (Advanced Level) Practise:1001. A+B Format