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

PAT 1002 写出这个数 (20 分)

作者: 昭明ZMing | 来源:发表于2018-12-11 14:38 被阅读0次
    #include<iostream>
    #include<string>
    using namespace std;
    int main()
    {
        long long sum = 0;
        string trans[10] = { "ling","yi","er","san","si","wu","liu","qi","ba","jiu" };
        char ch;
        while (1) {
            ch = getchar();
            if (ch == '\n')break;
            sum += ch - '0';
        }
        string cs = to_string(sum);
        for (int i = 0; i < cs.length(); i++) {
            cout << trans[cs[i]-'0'];
            if (i != cs.length() - 1)
                cout << " ";
        }
        return 0;
    }
    

    GitHub

    相关文章

      网友评论

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

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