AcWing 1477. 拼写正确
原题链接
简单
作者:
xybh
,
2021-02-16 13:10:58
,
所有人可见
,
阅读 386
模拟
#include<bits/stdc++.h>
using namespace std;
string en[] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
vector<string> ans;
long long sum;
int main(){
// 防止数字过大,无法存下
string num;
cin >> num;
// 特判num不为0
if(num == "0") {
cout << "zero";
return 0;
}
for(int i = 0; i < num.size(); i++){
sum += num[i] - '0';
}
while(sum != 0){
int index = sum % 10;
sum /= 10;
ans.push_back(en[index]);
}
reverse(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); i++){
cout << ans[i] << " ";
}
return 0;
}