1001 A+B Format (20)(20 分)

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

注意几个输出点:-991  991 1001 -1001
 #include<iostream>
#include <sstream>
#include<string>
#include<stack>
#include<typeinfo> using namespace std; int main()
{
int a,b,flag=,temp=; cin>>a>>b; a+=b; if(a<)
{
flag=;
cout<<"-";
} stringstream ss;
ss<<a; string str=ss.str(); stack<char> s; for(int i=str.length()-;i>=flag;--i)
{
s.push(str[i]);
++temp; if(temp%== && i->=flag)
s.push(',');
} while(!s.empty())
{
cout<<s.top();
s.pop();
} cout<<endl; return ;
}

PAT 甲级 1001 A+B Format (20)(20 分)的更多相关文章

  1. PAT甲级 1001 A+B Format

    题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 1001 A+B Format ( ...

  2. PAT 甲级1001 A+B Format (20)(C++ -思路)

    1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...

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

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

  4. PAT甲级——1001 A+B Format (20分)

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

  5. PAT 甲级 1001 A+B Format

    https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 Calculate a + b and ou ...

  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. PAT甲级:1136 A Delayed Palindrome (20分)

    PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...

  8. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

  9. PAT甲级:1089 Insert or Merge (25分)

    PAT甲级:1089 Insert or Merge (25分) 题干 According to Wikipedia: Insertion sort iterates, consuming one i ...

随机推荐

  1. nginx安装,配置,并可以放静态文件教程

    简单介绍一下:nginx是一个高性能的HTTP和反向代理的服务器.能有处理最高5,0000的并发量,是新兴的一个代理服务器.中国大陆使用nginx网站用户有:百度.京东.新浪.网易.腾讯.淘宝等. 安 ...

  2. 关于js 异步回调的一些方法

    http://www.ruanyifeng.com/blog/2012/12/asynchronous%EF%BC%BFjavascript.html

  3. eclipse + python + pydev

    工具:eclipse-nion.jdk8.python3.6.pydev eclipse -> help -> eclipse marketplace -> 输入 python,in ...

  4. 2017.4.28 KVM 内存虚拟化及其实现

    概述 KVM(Kernel Virtual Machine) , 作为开源的内核虚拟机,越来越受到 IBM,Redhat,HP,Intel 等各大公司的大力支持,基于 KVM 的开源虚拟化生态系统也日 ...

  5. 自我复制的3D打印机

    RepRap 是人类历史上第一部可以自我复制型的机器. https://reprap.org/wiki/RepRap RepRap 是一部可以生成塑料实物的免费桌面型 3D 打印机.由于 RepRap ...

  6. 查看win电脑支持的最大内存?

    wmic memphysical get maxcapacity 67108864 大约64G

  7. R49 A-D D图有向有环图

    A. Palindromic Twist 给一个字符串(小写字母)   每个字符+1,-1:变成其他字符  a只能变b  z只能变y 看能否变成回文字符串 #include<bits/stdc+ ...

  8. hdu4553 约会安排 线段树

    寒假来了,又到了小明和女神们约会的季节. 小明虽为屌丝级码农,但非常活跃,女神们常常在小明网上的大段发言后热情回复“呵呵”,所以,小明的最爱就是和女神们约会.与此同时,也有很多基友找他开黑,由于数量实 ...

  9. python argv传递参数

    test.pyimport sysprint(sys.argv) python test.py arg1 arg2 arg3 打印["test.py","arg1&quo ...

  10. 发布自己的npm包

    如何发布自己写的npm包,这里有详细解释 : https://blog.csdn.net/u010130282/article/details/82629924 本文旨在解释遇到的问题: 1:需要设置 ...