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. for...else 小记

    for ......: ...... else: ...... 在 for 循环中,若没有执行 break ,正常结束,则会执行 else 中的语句. 若执行了 break , 则 不会 执行 els ...

  2. Redis Cluster日常操作命令梳理

    在之前的一篇文章已经介绍了Redis Cluster及其部署,下面说下Redis Cluster日常操作命令: 一.以下命令是Redis Cluster集群所独有的,执行下面命令需要先登录redis: ...

  3. B. Interesting drink

    链接 [http://codeforces.com/group/1EzrFFyOc0/contest/706/problem/B] 题意 给你n个数,q次查询,每次输入一个m,问n个数中有多少个数小于 ...

  4. oracle数据库添加新用户

    /*分为四步 */ /*第1步:创建临时表空间 */ create temporary tablespace kmyf_temp tempfile 'E:\app\pangxy\product\11. ...

  5. Individual P1: Summary

    经过5个小时成功把simple mode写差不多了..orz 也是蛮拼的. 开始毫无头绪,本能地开始从度娘搜索‘c# 单词统计’= =看了两段代码也算是见过c#的人了.差不多花了我1小时的时间. 然后 ...

  6. 《Linux内核设计与实现》第四章学习笔记

    <Linux内核设计与实现>第四章学习笔记           ——进程调度 姓名:王玮怡  学号:20135116 一.多任务 1.多任务操作系统的含义 多任务操作系统就是能同时并发地交 ...

  7. JavaScript —— 数组

    Array方法 1.查找元素 indexOf()用来查找传进来的参数在目标数组中是否存在.如果目标数组包含该参数,就返回该元素在数组中的索引:如果不包含,就返回-1. 如果数组中包含多个相同的元素,i ...

  8. 文件I/O操作

    熟悉文件的各种流类 了解字符的编码 掌握文件I/O操作的相关概念 了解对象的序列化 简单的引入 I:input  由外围输入到内存 O:output  由内存写出到外存. I/O:是相对于内存来说的 ...

  9. Estimating the number of receiving nodes in 802.11 networks via machine learning

    来源:IEEE International Conference on Communications 作者:Matteo Maria 年份:2016 摘要: 现如今很多移动设备都配有多个无线接口,比如 ...

  10. NoSuchBeanDefinitionException:No qualifying bean of type

    Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException ...