题意:给出俩个整数a,b(不超过10^9) ,求a+b的值 ,并按照xxx,xxx,xxx的格式输出

#include <iostream>
using namespace std;
int main() {int a, b;cin >> a >> b;string s = to_string(a + b);int len = s.length();for (int i = 0; i < len; i++) {cout << s[i];if (s[i] == '-') continue;if ((i + 1) % 3 == len % 3 && i != len - 1) cout << ",";}return 0;
}

转载于:https://www.cnblogs.com/chenchen-12/p/10084579.html

1001 A+B Format (20 分)相关推荐

  1. 【PAT甲】1001 A+B Format (20分) 格式化输出

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

  2. 1001 A+B Format (20分)——12行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Calculate a+b and output the sum in standard format – that is, th ...

  3. 【PAT (Advanced Level) Practice】1001 A+B Format (20 分)

    #include<iostream> #include<string> #include<cstring> #include<cstdio> #incl ...

  4. 1001 A+B Format (20 分)【难度: 简单 / 知识点: 模拟】

    https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 方法一: #include<bits/ ...

  5. PTA 甲级 1001 A+B Format (20分)

    这题我不会,是抄的刘婼大神的.地址如下 地址 #include <iostream> #include<string> using namespace std; int mai ...

  6. PAT-PAT (Advanced Level) Practise 1001. A+B Format (20) 【二星级】

    题目链接:http://www.patest.cn/contests/pat-a-practise/1001 题面: 1001. A+B Format (20) Calculate a + b and ...

  7. PAT甲题题解-1001. A+B Format (20)-字符串处理,水

    计算A+B的和,并且按标准格式处理,每3个就要有个逗号 #include <iostream> #include <cstdio> #include <algorithm ...

  8. 1001. A+B Format (20)---------------PAT开始

    今天是第一次用Java提交PAT的代码: 源代码不能直接提交,需要经过修改: 源代码: 1 package test;//提交时不能显示这句 2 3 import java.util.Scanner; ...

  9. 1001.A+B Format (20) 解题

    代码入口(https://github.com/NSDie/object-oriented) 这题的解题思路我有两个: 第一个是两个数字相加然后判断位数,因为题目限制了范围1000000的绝对值以内嘛 ...

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

    ---恢复内容开始--- 题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 对于该题 ...

最新文章

  1. sklearn——CountVectorizer详解
  2. svn错误 is already locked 解决方案
  3. 团队作业10——复审与事后分析(Beta版本)
  4. rg1 蓝光危害rg0_LED(护眼)台灯|蓝光那些事
  5. leetcode 452. 用最少数量的箭引爆气球(贪心算法)
  6. 我们出了套西游记考题,可以保证吴承恩不及格
  7. php分页显示数据表格显示,php+layui数据表格实现数据分页渲染代码
  8. SQL:pgsql查询geom参考系以及更改geom参考系
  9. 路孚特:金融行业数据复杂 成本高 难获取 看路孚特如何打破困局
  10. java api1.8中文版(由谷歌,百度,有道,必应翻译)
  11. SPSS作业-方差分析-双因素分析
  12. 电商“论贱”血拼 传统书店该何去何从
  13. 百度图片爬虫【图片编码处理】
  14. 香橙派PC Plus电脑开发板制作网络打印服务器
  15. Java课后题第十三章:13.4(显示日历)
  16. return返回值详解
  17. 转自蒋宇(MTK WAP和MMS网络服务配置 )
  18. Green Plum 非并行备份恢复方案
  19. 《走进人工智能》学习笔记
  20. QNX系统下开启SSH服务步骤

热门文章

  1. STM32CubeMx HAL库使用硬件IIC读写AT24C02
  2. 原生Js 两种方法实现页面关键字高亮显示
  3. jacky解读麻省理工《计算机科学与Python编程导论》第1集
  4. Java2017面试宝典--XML部分、 流行的框架与新技术、软件工程与设计模式、 j2ee部分、EBJ部分、 webservice部分...
  5. 201571030128/201571030118《小学四则运算练习软件软件需求说明》结对项目报告
  6. iOS开发学习-nonatomic和atomic的区别
  7. 一张图说明我们为什么要关注 HTML5
  8. ASP.NET小技巧——回传后保持页面的滚动位置
  9. java跨函数跳转_VS code 函数无法跨文件跳转到定义
  10. 支付宝支付-手机浏览器H5支付