PAT1005
#include<iostream> #include<string> #include<map> using namespace std; map<int, string> m = {{0, "zero"}, {1, "one"}, {2, "two"}, {3, "three"}, {4, "four"}, {5, "five"}, {6, "six"}, {7, "seven"}, {8, "eight"}, {9, "nine"}}; int main() { string num; while(cin>>num) { int sum = 0; for(auto i : num) { sum += i - '0'; } string _sum = to_string(sum); cout<<m[_sum[0]-'0']; for(int i = 1; i < _sum.length(); i++) { cout<<" "<<m[_sum[i]-'0']; } } return 0; }