// PAT-A-1001
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <sstream>
#include <vector>
#include <stack>
using namespace std;
int main(int argc, const char * argv[]) {
int a,b;
cin>>a>>b;
int c=a+b;
int f1=0;
if (c<0) {
f1=1;
c=-c;
}
stack<char> re;
if(c==0){
cout<<"0";
return 0;
}
int cnt=0;
if (f1==1) {
cout<<"-";
}
while (c!=0) {
cnt++;
re.push(c%10+'0');
if (cnt==3&&c>=10) {
re.push(',');
cnt=0;
}
c/=10;
}
while (!re.empty()) {
cout<<re.top();
re.pop();
}
return 0;
}
PAT-A 1001. A+B Format (20)
猜你喜欢
转载自blog.csdn.net/ken_for_learning/article/details/78152670
今日推荐
周排行