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. Centos 6.9下部署Oracle 11G数据库环境的操作记录

    操作系统:Centos6.9(64Bit)Oracle:11g .11.2.0.4.0版本Ip地址:172.16.220.139 废话不多说了,下面记录安装过程:1)安装桌面环境 [root@vm01 ...

  2. rrd文件及rrd文件与实际数据的对比研究。

    一,什么是rrd文件? 所 谓的“Round Robin” 其实是一种存储数据的方式,使用固定大小的空间来存储数据,并有一个指针指向最新的数据的位置.我们可以把用于存储数据的数据库的空间看成一个圆,上 ...

  3. 浅谈meta viewport设置移动端自适应

    1.viewport 移动设备上的viewport是设备屏幕上用来显示网页的那部分区域,再具体一点就是浏览器上用来显示网页的那部分区域,但viewport又不局限于浏览器可视区域的大小,它可能比浏览器 ...

  4. 实验--使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用(杨光)

    使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用 攥写人:杨光  学号:20135233 ( *原创作品转载请注明出处*) ( 学习课程:<Linux内核分析>MOOC课程 ...

  5. 小学四则运算APP 第一个冲刺阶段 第六天

    团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是重新排列整齐ResultActivity的布局代码activity_result. ...

  6. MSA微服务

    https://github.com/das2017?tab=repositories https://github.com/icsharpcode/ILSpy/releases LayerDemo ...

  7. Linux下运行Shell脚本或者可执行文件Executable方法

    绝对路径 /xxx/xxx/something.sh /xxx/xxx/executable 相对路径 ./something.sh ./executable 注意:前边得加./,可不是像window ...

  8. OpenCV Code: Operations on Mat element

    cv::Mat img = cv::imread("image.jpg"); Method 1: img.at<uchar>(i, j, k) Method 2: im ...

  9. Angular require(抄别的)

    require参数的值可以用下面的前缀进行修饰,这会改变查找控制器时的行为:?如果在当前指令中没有找到所需要的控制器,会将null作为传给link函数的第四个参数.^如果添加了^前缀,指令会在上游的指 ...

  10. 常见的HTTP报头(头参数)

    本内容摘抄自<RESTful WebServices> 中文译本附录C '常见的HTTP报头'. 原文作者:Leonard Ricbardson & Sam Ruby 翻译:徐涵. ...