PAT甲级1001. A+B Format (20)
2016-01-01 21:40
573 查看
Sample Output时间限制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).InputEach 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.OutputFor 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 9
-999,991
#include<stdio.h> int main() { int a,b,c; scanf("%d%d",&a,&b); c=a+b; if(c>=1000000||c<=-1000000) { if(c>=0) printf("%d,%03d,%03d",c/1000000,(c%1000000)/1000,c%1000); else printf("%d,%03d,%03d",c/1000000,-(c%1000000)/1000,-c%1000); } else if(c>=1000||c<=-1000){ if(c>=0) printf("%d,%03d",c/1000,c%1000); else printf("%d,%03d",c/1000,-c%1000); } else { if(c>=0) printf("%d",c); else printf("%d",c); } return 0; }
相关文章推荐
- hello MemSQL 入门安装演示样例
- Glassfish Active Directory SSL LDAP JNDI
- 学习母函数感慨
- Mac下同时安装多个版本的JDK
- zzuoj--1001--汽水瓶(简单数学)
- linux ssh 免密码登陆
- HDU 2824 The Euler function(欧拉函数)
- ORM greenDAO基本用法
- Android开发 更改返回button的图标
- zzuoj--1001--汽水瓶(简单数学)
- 文章标题
- mac x Yosemide(10.10) 下安装 jdk 1.7 (jdk 1.8) 要求Mac OS X10.7.3或更高版本解决
- 单例模式...(ARC方式)
- CentOS更改yum源与更新系统
- POJ 1852 Ants (贪心)
- C#中异步及winform中界面假死
- OSS设置CORS规则以后还是报No 'Access-Control-Allow-Origin'解决方法
- win32api pywin32 安装后出现 ImportError: DLL load failed
- 搭建MiniGUI开发环境
- CentOS-7-x86_64-DVD-1503-01安装盘中Package包中的 软件