题目地址
很简单,仔细读题就可以
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
int c = a + b;
int f = 1;
if(c < 0){
c = -c;
f = -1;
}
stack<char> s;
if(c < 1000){
cout << c * f << endl;
}else{
int d = 0;
while(c != 0){
d++;
int t = c % 10;
c /= 10;
s.push( t + '0');
if(d == 3){
d = 0;
s.push(',');
}
}
if(f == -1) cout << "-";
if(s.top() == ','){
s.pop();
}
while(!s.empty()){
cout << s.top();
s.pop();
}
}
return 0;
}