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. wpf listview 行变色

    <ListView x:Name="listView_Date" Grid.Row="3" BorderBrush="{x:Null}" ...

  2. 使用$_SERVER['HTTP_HOST']时需注意的

    在php中,我们一般通过$_SERVER['HTTP_HOST']来活得URL中网站的域名或者ip地址. $_SERVER['HTTP_HOST']在客户的环境里,取得的值总是程序所在的服务器在其局域 ...

  3. Java定时任务器

    java定时任务,每天定时执行任务.以下是这个例子的全部代码. public class TimerManager { //时间间隔 private static final long PERIOD_ ...

  4. 在spring拦截器中response输出html标签到页面

    @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object ...

  5. NYOJ-914 Youth的最大化(贪心)

    Youth的最大化 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 Yougth现在有n个物品的重量和价值分别是Wi和Vi,你能帮他从中选出k个物品使得单位重量的价值最大吗? ...

  6. .net导出不规则Excel

    using Hamp.App.BLL; using Hamp.App.Model; using Hamp.App.Model.QualityManagement; using System; usin ...

  7. 对web.config加密,和解密码详细说明

    可以使用受保护配置来加密 Web 应用程序配置文件(如 Web.config 文件)中的敏感信息(包括用户名和密码.数据库连接字符串和加密密钥).对配置信息进行加密后,即使攻击者获取了对配置文件的访问 ...

  8. MUI——页面的创建、显示、关闭

    一.打开子页面 mui.init({ subpages:[{ url:your-subpage-url,//子页面HTML地址,支持本地地址和网络地址 id:your-subpage-id,//子页面 ...

  9. HTTP Basic Authentication认证的各种语言 后台用的

    访问需要HTTP Basic Authentication认证的资源的各种语言的实现 无聊想调用下嘀咕的api的时候,发现需要HTTP Basic Authentication,就看了下. 什么是HT ...

  10. jQuery slideDown()--向下滑动

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...