PAT一道乙级题目求教大佬解惑
#include <stdio.h>#define SIZE 100
int main(void)
{
char num1;
char *num2;
int i,sum = 0,count;
scanf("%s",num1);
for(i= 0;num1 != '\0';i++)
{
sum += num1-'0';
}
int j = 0;
do
{
count = sum%10;
switch(count)
{
case 1:num2 = "yi ";break;
case 2:num2 = "er ";break;
case 3:num2 = "san ";break;
case 4:num2 = "si ";break;
case 5:num2 = "wu ";break;
case 6:num2 = "liu ";break;
case 7:num2 = "qi ";break;
case 8:num2 = "ba ";break;
case 9:num2 = "jiu ";break;
case 0:num2 = "ling ";break;
}
j++;
sum /= 10;
} while (sum);
for (int k = j-1;k >= 0;k--)
{
printf("%s",num2);
}
putchar('\b');
return 0;
}
有没有大佬帮忙看一看我这个代码哪里有问题,一直通不过测试{:10_277:} 已解决
页:
[1]