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<cstdio>
#include<iostream>
#include<string.h>
using namespace std;
int main(){
int a, b, c, sign = , bt;
char prt[];
scanf("%d%d", &a, &b);
c = a + b;
if(c < ){
c = - * c;
sign =;
}
int i = , tag = ;
do{
bt = c % ;
c = c / ;
prt[i++] = '' + bt;
tag++;
if(tag != && tag % == ){
prt[i++] = ',';
}
}while(c != );
if(prt[i - ] != ',')
prt[i] = '\0';
else
prt[i - ] = '\0';
if(sign == )
printf("-");
for(int j = strlen(prt) - ; j >= ; j--)
printf("%c", prt[j]);
cin >> a;
return ;
}

注意:在整个数字的最高位前不能有逗号。

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

  1. PAT A1001 A+B Format

    Calculate a+b and output the sum in standard format -- that is, the digits must be separated into gr ...

  2. PAT A1001 A+B Format (20 分)

    AC代码 #include <cstdio> #include <algorithm> using namespace std; const int maxn = 11; in ...

  3. PTA A1001&A1002

    从今天起每天刷1-2题PAT甲级 第一天 A1001 A+B Format (20 分) 题目内容 Calculate a+b and output the sum in standard forma ...

  4. PAT/字符串处理习题集(二)

    B1024. 科学计数法 (20) Description: 科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式[+-][1-9]"."[0-9]+E[+ ...

  5. PAT题目AC汇总(待补全)

    题目AC汇总 甲级AC PAT A1001 A+B Format (20 分) PAT A1002 A+B for Polynomials(25) PAT A1005 Spell It Right ( ...

  6. 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 ...

  7. Spring resource bundle多语言,单引号format异常

    Spring resource bundle多语言,单引号format异常 前言 十一假期被通知出现大bug,然后发现是多语言翻译问题.法语中有很多单引号,单引号在format的时候出现无法匹配问题. ...

  8. c# 字符串连接使用“+”和string.format格式化两种方式

    参考文章:http://www.liangshunet.com/ca/201303/218815742.htm 字符串之间的连接常用的两种是:“+”连接.string.format格式化连接.Stri ...

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

    题目原文: Calculate a + b and output the sum in standard format -- that is, the digits must be separated ...

随机推荐

  1. 分布式监控系统Zabbix--完整安装记录(7)-使用percona监控MySQL

    前面已经介绍了分布式监控系统Zabbix-3.0.3-完整安装记录(2)-添加mysql监控,但是没有提供可以直接使用的Key,太过简陋,监控效果不佳.要想更加仔细的监控Mysql,业内同学们都会选择 ...

  2. Docker容器学习梳理 - 容器时间跟宿主机时间同步

    在Docker容器创建好之后,可能会发现容器时间跟宿主机时间不一致,这就需要同步它们的时间,让容器时间跟宿主机时间保持一致.如下: 宿主机时间 [root@slave-1 ~]# date Fri M ...

  3. 最好使用%f输出浮点数据,acm

    今天做题的时候发现使用%lf输出的时候总是wrong,而一旦改成%f就ac了,询问学长后知道,不要用%lf输出,浮点都用%f 然而我还是有疑惑,如果%f容不下输出的数据怎么办呢? 于是我就去百度 原来 ...

  4. 12.24daily_scrum

    今天是平安夜,大家开心地度过一个平安夜的同时,也完成了很多软件的调试工作,我们争取在下周前完成本阶段的所有调试工作. 具体工作如下: 具体工作: 小组成员 今日任务 明日任务 工作时间 李睿琦 软件调 ...

  5. Beta版发布说明

    我们的作品“校友聊”软件的最终版本于6月19日最终发布了,下面我们将对自己的产品进行介绍. 在使用之前,首先要进行用户注册,用户可以自行设置自己的账号,姓名,密码,签名,头像等信息,头像信息也可以在文 ...

  6. Sprint 冲刺第三阶段第6-10天

    这几天一直都在整理我们之前的内容,检查会不会有细节问题.例如界面跳转.颜色等. 因为一直没办法找到guitub存放位置.于是在这里存放一些主代码. MainActivity.java package ...

  7. 第三个Sprint冲刺第九天(燃尽图)

  8. HDOJ2013_蟠桃记

    水题 HDOJ2013_蟠桃记 #include<stdio.h> #include<stdlib.h> #include<math.h> #include< ...

  9. Voltage Keepsake CodeForces - 801C (思维+二分)

    题目链接 这是一道很棒的二分题. 思路: 首先先思考什么情况下是可以无限的使用,即输出-1. 我们思考可知,如果每一秒内所有设备的用电量总和小于等于充电器每秒可以充的电,那么这一群设备就可以无限使用. ...

  10. WebLogic Server Components:XA Transactions

    https://docs.oracle.com/cd/E19509-01/820-5892/ref_xatrans/index.html Weblogic支持基于JPA规范的强一致性的XA事务,应对传 ...