c/c++语言开发共享1001 A+B Format (20 分)

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

题意:给出俩个整数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; }

 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/606020.html

(0)
上一篇 2021年5月13日
下一篇 2021年5月13日

精彩推荐