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<stack>
using namespace std;
int main() {
long a,b;
cin>>a>>b;
long res=a+b;
if(res==){
cout<<;
system("pause");
return ;
}
bool sign;
int m=;
if(res<) {
sign=false;
res=-res;
}
else sign=true;
stack<char> sta;
while(res!=){
m++;
sta.push(res%+'');
res/=;
if(m%==) sta.push(',');
}
if(sta.top()==',') sta.pop();
if(!sign) cout<<"-";
while(!sta.empty()){
cout<<sta.top();
sta.pop();
}
system("pause");
return ;
}

最新文章

  1. 面向对象Part4
  2. C/C++学习链接
  3. Ext3文件系统mount选项和文件属性介绍
  4. 《Storm入门》中文版
  5. Jquery,ajax返回json数据后呈现到html页面的$.post方式。
  6. selenium项目总结(UI自动化测试平台搭建、测试报告生成、邮件转发)
  7. poj 1180 斜率优化dp
  8. 【AngularJs】---表单验证
  9. ANT的下载和安装
  10. Usage、Usage Minimum和Usage Maximum项目详解
  11. 警告:‘xxxx’ 将随后被初始化
  12. 教程:查找内存泄漏 (JavaScript)
  13. CSharp设计模式读书笔记(17):迭代器模式(学习难度:★★★☆☆,使用频率:★★★★★)
  14. mysql 触发器(trigger)
  15. Java | 原来 try 还可以这样用啊?!
  16. python笔记三(list、tuple)
  17. 对C#热更新方案ILRuntime的探究
  18. 自己动手写Redis客户端- Redis协议(1)
  19. app开发中,前后端使用AES进行数据加密传输
  20. Nmap扫描命令使用详解

热门文章

  1. 从Java中的length和length()开始
  2. vue simple框架打包遇到报错问题
  3. CentOS 6.7与CentOS 7.3内存查看命令free、top的差异对比
  4. Promethus
  5. 通过helm 安装 harbor 不成功问题处理
  6. windows下eclipse打不开
  7. prism Callback应用
  8. Win7上防火墙开放FTP服务以及ping解决方案
  9. django的url的name参数的意义及view中reverse
  10. Git配置用户名、邮箱