PAT甲级备考
A+B Format
代码:
#include <iostream>
#include <stack>
using namespace std;
int main() {
int a, b; cin >> a >> b;
int c = a + b;
if(c < 0) cout << "-";
c = abs(c);
stack<int> st;
if(c == 0) {
cout << 0 << endl;
return 0;
}
int len = 0;
while(c) {
st.push(c % 10);
c /= 10;
len++;
}
while(st.size()) {
cout << st.top();
st.pop();
len--;
if(len % 3 == 0 && len != 0) cout << ",";
}
return 0;
}