PAT 1001

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <cstring>
#include <sstream>
using namespace std;
int main()
{
int a , b;
cin>>a>>b;
string num , num2;
stringstream ss;
int numf = a+b;
if(numf < 0)
{
cout<<"-";
numf = -numf;
}
ss<<numf;
ss>>num;
int cnt =0;
for(int i = num.size()-1 ; i >= 0 ; --i)
{
if(cnt && cnt < num.size() && cnt % 3 == 0)
num2 = "," + num2;
num2 = num[i] + num2;
++cnt;
}
cout<<num2<<endl;
return 0;
}

热评文章