题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400

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 Specification:

Each input file contains one test case. Each case contains a pair of integers a and b where −. The numbers are separated by a space.

Output Specification:

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 <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
using namespace std;
int main()
{
int n,m,sum;
while(cin>>n>>m){
sum=n+m;
if(sum==){
cout<<<<endl;
continue;
}
int flag=;
if(sum<){
flag=;
sum=-sum;
}
char c='-';
stack<char> s;
int t=;
while(sum){
c=sum%+'';
s.push(c);
t++;
if(t%==&&sum/) s.push(',');
sum/=;
}
if(flag) s.push('-');
while(!s.empty()){
cout<<s.top();
s.pop();
}
cout<<endl;
}
return ;
}
 

最新文章

  1. linux 学习随笔-shell基础知识
  2. 在不同的pyhon版本中切换
  3. CDN(内容分发网络)是什么?
  4. iOS - UIButton
  5. C++记录debug信息的log类
  6. 让你了解x86的中断
  7. Java Servlet-http协议
  8. wps 2012-2013 通杀漏洞(CVE-2013-3934)
  9. phpcms(1)phpcms V9 MVC模式 与 URL访问解析(转)
  10. 基于HttpClient 4.3的可訪问自签名HTTPS网站的新版工具类
  11. 第一章 C++基本认识
  12. Gradle构建Java工程配置详解
  13. python学习笔记1-python相关应用套件
  14. 搭建、访问ftp
  15. android组件之TabHost
  16. 设计模式 笔记 单例模式 Singleton
  17. WPF为stackpanel设置滚动条
  18. css样式冲突问题练习例子
  19. RSA加密的测试demo
  20. plotplayer声道设置原声

热门文章

  1. StringBuild使用与原理
  2. 使用JS获取input值
  3. Java课程2019年3月开学测试
  4. java保留小数后两位的四种写法
  5. ArcGIS JavaScript开发过程中,底图产生拼接缝问题
  6. swust oj 982
  7. EF Core 小坑:DbContextPool 会引起数据库连接池连接耗尽
  8. 阿里云服务器ssh经常一段时间就断掉解决办法
  9. iOS APP打开其他应用
  10. 2019/4/22 拓扑排序的高效写法. 模板题HDU1285:确定比赛名次