1001 A+B Format (20)

题目位置:https://www.patest.cn/contests/pat-a-practise/1001

 1 #include<stdio.h>
 2 #include<math.h>            //注意格式!!!!!!!!!! 
 3 int main()
 4 {
 5     long a,b,c;
 6     scanf("%ld %ld",&a,&b);
 7     c=a+b;
 8     if(c/1000000)
 9         printf("%ld,%03ld,%03ld",c/1000000,abs(c%1000000/1000),abs(c%1000000%1000));   //注意后面没有符号,长整型为ld 
10     else if(c/1000)
11         printf("%ld,%03ld",c/1000,abs(c%1000));                  //中间可能有0 !!!!!!!!!! 
12     else
13         printf("%ld",c);//三个一组,输出001之类 
14     return 0;
15 }

 

posted @ 2018-01-16 16:40  爱你的笑  阅读(90)  评论(0编辑  收藏  举报