1.题目介绍
2.考察点,难度
字符串处理类,映射对应关系,难度易
3.解题代码
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
string s,result;
int sum=0;
string english[]={"zero","one","two","three","four","five","six","seven","eight","nine"};
map<char, string> M;
for(int i=0;i<10;i++)
M.insert(pair<char, string>(i+'0',english[i]));
getline(cin,s);
for(int i=0;i<s.length();i++)
sum+=s[i]-'0';
result=to_string(sum);
cout<<M[result[0]];
for(int i=1;i<result.length();i++){
cout<<" "<<M[result[i]];
}
return 0;
}
4.原题地址
https://pintia.cn/problem-sets/994805342720868352/problems/994805519074574336