AcWing 1477. 拼写正确
原题链接
简单
作者:
hai阿卢
,
2021-03-12 00:28:51
,
所有人可见
,
阅读 301
#include<iostream>
#include<string>
using namespace std;
string a;
int main()
{
cin >> a;
string::iterator i;
int res = 0;
if(a == "0") cout << "zero";
for(i = a.begin(); i < a.end(); i++) res += (*i - '0');
string s;
while(res)
{
s.insert(0, 1, res % 10 + '0');
res = res /10;
}
for(i = s.begin(); i < s.end(); i++)
{
if(*i == '1') cout << "one" << " ";
if(*i == '2') cout << "two" << " ";
if(*i == '3') cout << "three" << " ";
if(*i == '4') cout << "four" << " ";
if(*i == '5') cout << "five" << " ";
if(*i == '6') cout << "six" << " ";
if(*i == '7') cout << "seven" << " ";
if(*i == '8') cout << "eight" << " ";
if(*i == '9') cout << "nine" << " ";
if(*i == '0') cout << "zero" << " ";
}
return 0;
}