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. 记一次在.NET成长之路上的下午茶

    在2017年2月25日我和李海国有幸与阳铭.朱永光两位大哥喝了一次下午茶.熟悉ABP框架的朋友呢知道阳铭远在上海,所以个人很是珍惜这次机会.朱永光大哥是微软MVP,之前是启路科技的CTO,目前在微软. ...

  2. 【下一代核心技术DevOps】:(六)Rancher集中存储及相关应用

    1. 前言 为什么要使用集中存储? 使用集中存储有个很大的优势是数据安全和统一管理,和集群完美配合. 产品集成存储经历过几个阶段: 1.单机本机存储. 系统使用本地硬盘存储 2.单网络集中存储. 局域 ...

  3. mysql 多主

    原理:多个msyql/mariadb之间可以实时同步,任意节点的操作可以立即同步到其他节点,底层采用galera插件同步,类似rsync,上层mysql相对于galera是透明的,可以实现多节点同时读 ...

  4. nginx的access.log文件详解

    事实证明,日志文件真的是很重要很重要的.能够帮助我们快速的定位问题,并且知道用户访问的状态,浏览器,Ip,接口地址等,简直可怕.. 一.nginx的access.log(1)对博主而言,日志文件存放在 ...

  5. js数组的用法

    1.数组 - - 添加元素 arr.push('abc')  向数组尾部添加元素,返回值为数组的长度 arr.unshift('abc')  向数组头部添加元素,返回值为数组的长度 2.数组 - - ...

  6. PHP使用Redis实现消息队列

    消息队列可以使用MySQL来实现,可以参考博客PHP使用MySQL实现消息队列,虽然用MySQL可以实现,但是一般不这么用,因为MySQL的数据都存在硬盘中,而从硬盘中对MySQL的操作,I/O花费的 ...

  7. python数据相关性分析 (计算相关系数)

    #-*- coding: utf-8 -*- #餐饮销量数据相关性分析 计算相关系数 from __future__ import print_function import pandas as pd ...

  8. Mac上brew&thrift安装 以及在thrift架构下,自己新作了maven的小例 Demo

    1.缘由 前几天偶尔在网上看到thrift的信息,其内容和作用极大的引起了我的兴趣,因为我也是做iOS开发的,通过在网上的查询发现信息虽然很多实用的很少,容易误导他人,经过自己的成功实践,做了笔录,为 ...

  9. zabbix2.2 - /tmp/FromDualMySQLagent.lock already exists

    最近升级了线上的zabbix server版本,升级成功后发现日志中一直报出history和history-uint表的主键冲突数据插入不成功的信息,根据主键冲突发生的itemid去库里查,如下 my ...

  10. async中await是干啥的,用不用有什么区别?

    最近在研究异步编程,用的async await task啥的,但是都这几个概念很模糊,还有不太清楚await是干啥的,task又是干啥的,用不用await有什么区别,他们三个之间的联系是什么? tas ...