1002 写出这个数 (20 分)

2019-03-05  本文已影响0人  zjh3029
#include<iostream>
#include<string>
#include<cmath>


using namespace std;

int main()
{
    string str,str1;
    int sum = 0;
    cin >> str;
    for (int i = 0; i < str.size(); i++)
    {
        sum += str[i]-'0';
    }
    str1 = to_string(sum);

    for (int i = 0; i < str1.size(); i++)
    {
        int a = str1[i] - '0';
        switch (a)
        {
        case 0:
            cout << "ling";
            break;
        case 1:
            cout << "yi";
            break;
        case 2:
            cout << "er";
            break;
        case 3:
            cout << "san";
            break;
        case 4:
            cout << "si";
            break;
        case 5:
            cout << "wu";
            break;
        case 6:
            cout << "liu";
            break;
        case 7:
            cout << "qi";
            break;
        case 8:
            cout << "ba";
            break;
        case 9:
            cout << "jiu";
            break;
        }
        if(i!=str1.size()-1)
            cout << " ";
    }
    cout << endl;
    system("pause");
    return 0;
}
上一篇下一篇

猜你喜欢

热点阅读