#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
freopen("D://input.txt", "r", stdin);
int a, b;
int ret, lgt, cut;
cin >> a >> b;
ret = a + b;
string output, temp;
if (ret < 0)
output = "-";
ret = fabs(ret);
temp = to_string(ret);
if (ret < 1000)
output += temp;
else if (ret >= 1000 && ret < 1000000) {
lgt = temp.length();
cut = lgt - 3;
output += temp.substr(0, cut) + "," + temp.substr(cut, 3);
}
else {
lgt=temp.length();
cut = lgt - 6;
output += temp.substr(0, cut) + "," + temp.substr(cut, 3) + "," + temp.substr(cut + 3, 3);
}
cout << output << endl;
return 0;
}
1001. A+B Format (20)
最新推荐文章于 2021-02-19 15:05:15 发布