2020-06-30//1002 写出这个数 (20分) 读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字。

错误xxxxx

#include 
using namespace std;
int main()
{
    char num[105] = { '0' };
    cin >> num;
    int sum = 0;
    int i = 0;
    while (num[i] != 0)
    {
        sum += num[i] - '0';
        i++;
    }
    char ch[][10] = { "ling","yi","er","san","si","wu","liu","qi","ba","jiu" };
    int m = 0;
    m = (sum % 100);
    if (m != 0)
    {
        cout << ch[m];
        sum = sum / 10;
    }
    m = (sum % 10);
    cout << ch[m];
    m = (sum / 10);
    cout << ch[m];
}

你可能感兴趣的:(2020-06-30//1002 写出这个数 (20分) 读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字。)