題意:給出倆個整數a,b(不超過10^9) ,求a+b的值 ,並按照xxx,xxx,xxx的格式輸出 ...
題意:給出倆個整數a,b(不超過10^9) ,求a+b的值 ,並按照xxx,xxx,xxx的格式輸出
#include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; string s = to_string(a + b); int len = s.length(); for (int i = 0; i < len; i++) { cout << s[i]; if (s[i] == '-') continue; if ((i + 1) % 3 == len % 3 && i != len - 1) cout << ","; } return 0; }