标签:alc group mes cout form ios ted a+b tst
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).
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.
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.
-1000000 9
-999,991
1 #include<iostream>
2 #include<cstring>
3 #include<cmath>
4 #include<algorithm>
5 #include<map>
6 using namespace std;
7 int main()
8 {
9 int a,b,sum;
10 cin>>a>>b;
11 sum=a+b;
12 string str;
13 str=to_string(sum);
14 for(int i=0;i<str.size();i++)
15 {
16 if((str.size()-i-1)%3==0&&str[i]!=‘-‘&&i!=str.size()-1)
17 cout<<str[i]<<",";
18 else
19 cout<<str[i];
20 }
21 return 0;
22 }
标签:alc group mes cout form ios ted a+b tst
原文地址:https://www.cnblogs.com/xwl3109377858/p/10660646.html