美文网首页
1002 写出这个数 (20 分)

1002 写出这个数 (20 分)

作者: zjh3029 | 来源:发表于2019-03-05 16:35 被阅读0次
    #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;
    }
    

    相关文章

      网友评论

          本文标题:1002 写出这个数 (20 分)

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