1001. A+B Format (20)
来源:互联网 发布:k歌达人 网络异常 编辑:程序博客网 时间:2024/06/06 02:54
1001. A+B Format (20)
时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).
Input
Each input file contains one test case. Each case contains a pair of integers a and b where -1000000 <= a, b <= 1000000. The numbers are separated by a space.
Output
For each test case, you should output the sum of a and b in one line. The sum must be written in the standard format.
Sample Input-1000000 9Sample Output
-999,991
#include<stdio.h>int main(){ int i,j,n,m,k,t; int a[100]; while(scanf("%d %d",&n,&m)!=EOF) { k=n+m; if(k==0) printf("0"); if(k<0) { printf("-"); k=-k; } i=0; while(k!=0) { a[i++]=k%10; k/=10; } for(j=i-1;j>=0;j--) { printf("%d",a[j]); if(j%3==0&&j!=0) printf(","); } printf("\n"); }}
0 0
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- 1001. A+B Format (20)
- mysql-5.7.11-winx64.zip 安装配置
- Python 生成随机数
- Discuz!后台程序目录/source/admincp/下目录及文件功能详解
- 不要用for in语句对数组进行遍历
- 关于 HttpURLConnection POST请求 上传 以及中文乱码问题
- 1001. A+B Format (20)
- 解决Qt Designer.exe启动后,界面不显示的问题
- TCP的连接和断开详解
- JavaScript从作用域到闭包
- 特殊字符html,css转义大全
- 过拟合、正则
- Sigmoid 函数和 Tanh 函数的区别
- Halcon学习(二) Halcon基本操作:批量读入本地文件夹内的图片
- iOS中导航控制器的使用 UINavigationController