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. width,height为多少px时,A4纸打印时刚好一页?

    计算方式一般的分辨率为XX像素/英寸,其中一英寸为25.4毫米.所以一毫米的像素数就为XX/25.4.现在的工作就是求XX的值了,把XX的值求出来以后,直接用XX/25.4 * 210就得到A4纸的像 ...

  2. [原]Veracrypt使用Yubikey作为安全令牌

    今天刚刚到货Yubikey 5 美亚 直邮 ,易客满国际,国内居然是顺丰配送,点个赞. 必备的控件 https://developers.yubico.com/yubikey-manager-qt/R ...

  3. json中获取key值

    <script type="text/javascript"> getJson('age'); function getJson(key){ var jsonObj={ ...

  4. Python迭代器(Iterator)

    概述 迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束.迭代器只能往前不会后退. 延迟计算或惰性求值 (Lazy evaluation) 迭代器不要求你 ...

  5. 12.18 Daily Scrum

    最近大家确实都很忙,所以所有功能的实现要等到下周.   Today's Task Tomorrow's Task 丁辛 实现和菜谱相关的餐厅列表. 实现和菜谱相关的餐厅列表.             ...

  6. Maven的课堂笔记4

    9.Maven与MyEclipse2014结合 MyEclipse10以上的版本,对Maven支持的就比较好 9.2 Myeclipse配置 本地文件夹的C盘的.m2文件夹下必须得有这个setting ...

  7. 自己写的browse.bat与perl写的url_handler.pl的比较

    以前自己也写过Windows下自动打开多个浏览器测试某个URI,提高浏览器兼容性测试效率. 但是写的browse.bat文件还是最基础简陋的 @echo off if '%1'=='-c' ( sta ...

  8. RocketMQ事务消息实战

    我们以一个订单流转流程来举例,例如订单子系统创建订单,需要将订单数据下发到其他子系统(与第三方系统对接)这个场景,我们通常会将两个系统进行解耦,不直接使用服务调用的方式进行交互.其业务实现步骤通常为: ...

  9. sap 最新财报以及云业务转型情况

    SAP第四季度收入超预期 加码云转型启动重组计划 http://soft.zhiding.cn/software_zone/2019/0130/3115457.shtml 尽管第四季度超出收入预期,但 ...

  10. file_put_contents () failed to open stream: Permission denied 解决办法

    今天,帮朋友配置服务器thinkphp5的时候,直接访问“www.***.com/admin/index/index” : 出现以下错误: file_put_contents (/PHP/admin/ ...