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 9

Sample Output

-999,991

程序代码:*

#include<stdio.h>
int main()
{
  int a,b,sum;
  scanf("%d%d",&a,&b);
  sum=a+b;
  if(sum<0)
    printf("-");
  if(abs(sum)<1000)
  printf("%d",abs(sum));
  if(abs(sum)>=1000&abs(sum)<1000000)
  printf("%d,%03d",abs(sum)/1000,abs(sum)%1000);
  if(abs(sum)>=1000000&abs(sum)<=2000000) 
  printf("%d,%03d,%03d",abs(sum)/1000000,abs(sum)/1000%1000,abs(sum)%1000);
  return 0;
}

1001. A+B Format的更多相关文章

  1. 1001.A+B Format (20)代码自查(补足版)

    1001.A+B Format (20)代码自查(补足版) 谢谢畅畅酱的提醒,发现了代码中的不足,把变量名更改成更合理的名字,并且把注释也换成英文啦! 栋哥提供的代码自查的方式也帮助了我发现很多代码中 ...

  2. PAT甲级 1001 A+B Format

    题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 1001 A+B Format ( ...

  3. PAT 甲级 1001 A+B Format (20)(20 分)

    1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...

  4. PAT 甲级1001 A+B Format (20)(C++ -思路)

    1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...

  5. 1001.A+B Format(10)

    1001.A+B Format(20) github链接:[example link](https://github.com/wgc12/object-oriented 1.对题目的理解: 首先这道题 ...

  6. PTA (Advanced Level) 1001 A+B Format

    1001 A+B Format Calculate a+b and output the sum in standard format -- that is, the digits must be s ...

  7. PAT 1001. A+B Format 解题

    GitHub PDF 1001. A+B Format (20) Calculate a + b and output the sum in standard format -- that is, t ...

  8. 1001 A+B Format (20 分)

    1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits mu ...

  9. PAT甲 1001. A+B Format (20) 2016-09-09 22:47 25人阅读 评论(0) 收藏

    1001. A+B Format (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Calculate ...

  10. 关于‘1001.A+B Format (20)’的解题报告

    1001.A+B Format(20) 首先要感谢一下指导我github上传问题的小伙伴们,捣腾了一整天我终于摸到了一点门路,真的谢谢你们. 小豪的github 问题描述: Calculate a + ...

随机推荐

  1. 构建maven的web项目时注意的问题

    构建项目后或者导入项目后,我们需要bulid path--->config build path 特别是maven的依赖一定要 发布到WEB_INF的lib下面,不然在发布项目的时候,这些依赖都 ...

  2. EFI安装Win7

    安装系统之前电脑里最好没有其他系统,安装过程中电脑需重启多次,其他系统会引导电脑开机,无法完成WIN7安装. 一.制作安装分区 1.首先在移动硬盘(U盘)准备一个FAT32分区 一定要FAT32分区, ...

  3. tableView区头不显示

    不知道什么原因 如果设置tableView的样式为Group 则必须写代理 p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; co ...

  4. 不同浏览器对URL最大长度的限制

    不同浏览器对URL最大长度的限制   1.今天碰到一个bug,window.open后面的页面,接收参数不全,导致后台报错.实验了一下.发现是使用get方法请求服务器时,URL过长所致 微软官方的说明 ...

  5. SQL语句优化技术分析 整理他人的

    一.操作符优化 1.IN 操作符 用IN写出来的SQL的优点是比较容易写及清晰易懂,这比较适合现代软件开发的风格.但是用IN的SQL性能总是比较低的,从Oracle执行的步骤来分析用IN的SQL与不用 ...

  6. iOS 如何随意的穿插跳跃,push来pop去

    OS 如何随意的穿插跳跃,push来pop去 主题思想:如A.B.C.D 四个视图控制器 想要在 A push B 后, B 在push 到 D ,然后从 D pop 到 C ,在从 C pop 的A ...

  7. oAuth 使得第三方无需使用用户的用户名与密码就可以申请获得该用户资源的授权

    OAUTH协议为用户资源的授权提供了一个安全的.开放而又简易的标准.与以往的授权方式不同之处是OAUTH的授权不会使第三方触及到用户的帐号信息(如用户名与密码),即第三方无需使用用户的用户名与密码就可 ...

  8. java 生成证书用于https

    在jdk的bin目录下运行: keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore " ...

  9. ios9 新关键字 __kindof 等(etc) 小结

    首先__kindof:规定参数为UITableViewCell(举例)这个类或者其子类.比如说一个NSArray<UIView *>*,如果不加__kindof,这个数组只能有UIView ...

  10. SSM

    今天内容安排 1:复习mybatis 2:复习springMVC 3:springMVC+spring+mybatis组合起来,搭建一个web应用开发的框架 4:用户管理系统,针对用户的CRUD操作, ...