回复 2楼 c小白2333
题目:把n的每一位加起来,用汉语拼音输出sum的每一位
#include <stdio.h>
void num(int num);
int main()
{
int n;
scanf("%d",&n);
int i;
int mask = 1;
int a=n;
int sum = 0;
while (a>0)
{
sum+=a%10;
a /= 10 ;
}
a =sum;
while (a>9)
{
a /= 10;
mask *= 10;
}
mask *=10;
while(mask>0)
{
num = sum/mask;
sum %= mask;
mask/=10;
num(num);
printf(" ");
if(mask == 0)
printf("%b");
}
return 0;
}
void num(int num)
{
switch (num)
{
case 0 : printf("ling");break;
case 1 : printf("yi");break;
case 2 : printf("er");break;
case 3 : printf("san");break;
case 4 : printf("si");break;
case 5 : printf("wu");break;
case 6 : printf("liu");break;
case 7 : printf("qi");break;
case 8 : printf("ba");break;
case 9 : printf("jiu");break;
}
}