计算A+B的和,并且按标准格式处理,每3个就要有个逗号

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std; int main()
{
int a,b;
scanf("%d %d",&a,&b);
int sum=a+b;
char str[];
sprintf(str,"%d",sum); //将num按指定格式输入到str字符串中
int idx=;
if(sum<){
printf("-");
idx=;
}
int len=strlen(str);
for(int i=idx;i<len;i++){
printf("%c",str[i]);
int left=len-i-;
//剩下的个数是3的倍数的话,就要输出','。当然最后一位除外
if(left%== && i!=len-)
printf(",");
}
printf("\n");
return ;
}

最新文章

  1. 必杀技———SQL基础整理系列(一)
  2. navicat在ubuntu下中文乱码的真正解决方法ZT
  3. shell下的作业管理[转]
  4. weblogic性能调优参考
  5. JavaScript constructor 属性
  6. [Wordpress]Wordpress使用SMTP发送电邮
  7. SCVMM问题汇总
  8. css3 -&amp;gt; 多栏布局
  9. jQuery -&amp;gt; bind / live / delegate 终结者 - on
  10. python+appium使用记录
  11. iOS客户端开发与Web前端开发
  12. Python学习之一:Python2.7与opencv2.4安装配置
  13. 【leetcode78】Single Number II
  14. 携程Apollo一键编译脚本+部署实现
  15. Do You Kown Asp.Net Core -- Asp.Net Core 2.0 未来web开发新趋势 Razor Page
  16. Linux基础命令---ipcs显示进程通信
  17. Java:JavaBean和BeanUtils
  18. 记录一次.Net框架Bug发现和提交过程:.Net Framework和.Net Core均受影响
  19. Error starting ApplicationContext. To display the conditions report re-run your application with &#39;debug&#39; enabled.
  20. Emoji 编码

热门文章

  1. Dalvik指令备忘
  2. 陈远波(java)--Git 入门
  3. 给SVN设置代理
  4. Hive 整合Hbase
  5. Scala学习之路 (三)Scala的基本使用
  6. layui 弹出层监听 判断弹出框的大小
  7. Hibernate-validator校验框架使用
  8. android中如何获取指定目录下的图片
  9. leetcode63&mdash;Unique Path II
  10. Python3.6使用Pyqt5编写GUI程序