1005 Spell It Right (20)

2018-07-26  本文已影响0人  zjh3029
#include <iostream>
#include <string> 
using namespace std;

int main()
{
    string str;
    string res_str[10] = { "zero","one","two","three","four","five","six","seven","eight","nine" };
    cin >> str;
    int sum = 0;
    for (auto c:str)
    {
        sum+=c-'0';
    }
    string s = to_string(sum);
    bool flag = false;
    for (auto c : s)
    {
        int index= c - '0';
        if (flag==false)
        {
            cout << res_str[index];
            flag =true;
        }
        else
        {
            cout << " "<<res_str[index];
        }
    }
    system("pause");
    return 0;
}
上一篇 下一篇

猜你喜欢

热点阅读