AcWing 1477. 拼写正确
原题链接
简单
作者:
Value
,
2020-05-22 14:50:11
,
所有人可见
,
阅读 531
#include <iostream>
#include <vector>
using namespace std;
string s[10] = {"zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine"
};
int main(){
string t; cin >> t;
int cnt = 0;
for(int i = 0; i < t.size(); i ++ ) cnt += (t[i] - '0');
vector<string> res;
while(cnt){
res.push_back(s[cnt % 10]);
cnt /= 10;
}
if(res.size() == 0) res.push_back("zero");
for(int i = res.size() - 1; i >= 0; i -- ){
cout << res[i];
if(i) cout << ' ';
else cout << endl;
}
return 0;
}