【1001】A+B Format(20分)
1 #include<iostream> 2 #include<string> 3 using namespace std; 4 int main() { 5 int a, b; 6 int sum = 0; 7 cin >> a >> b; 8 sum = a + b; 9 string s = to_string(sum); 10 for (int i = 0; i < s.length(); i++) { 11 cout << s[i]; 12 if (s[i] == '-') 13 continue; 14 if ((i + 1) % 3 == s.length() % 3 && i != s.length() - 1) 15 cout << ","; 16 } 17 return 0; 18 }