美文网首页
1005 Spell It Right (20)

1005 Spell It Right (20)

作者: zjh3029 | 来源:发表于2018-07-26 18:00 被阅读0次
#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;
}

相关文章

网友评论

      本文标题:1005 Spell It Right (20)

      本文链接:https://www.haomeiwen.com/subject/jdtimftx.html