一个不超过10位的数字,要显示每个数字对应英文,程序不知道哪里出错,10位数字老错

来源:互联网 发布:三国杀菜刀的淘宝 编辑:程序博客网 时间:2024/05/17 04:11

#include<stdio.h>#include<math.h>int main(void){     int a,x,number,y,z,j;     float b;     double m,n;     long int i;     printf("Please enter a number but no larger than 10 digits:");     scanf_s("%d",&a);     number=0;     n=10;     for (i=1;i<=a;i=i*10)//count number of digitals      {         number=number+1;     }     z=number;     for (j=z;j>0;j--)     {            m=j-1;         x=pow(n,m);         b=a/x;         y=(int)b;         switch (y)     {        case 0: // if y=0            printf("zero"); // print zero            break; // terminate        case 1: // if y=1            printf("one"); // print one            break; // terminate        case 2: // if y=2            printf("two"); // print two            break; // terminate        case 3: // if y=3            printf("three"); // print three            break; // terminate        case 4: // if y=4            printf("four"); // print four            break; // terminate        case 5: // if y=5            printf("five"); // print five            break; // terminate        case 6: // if y=6            printf("six"); // print six            break; // terminate        case 7: // if y=7            printf("seven"); // print seven            break; // terminate        case 8: // if y=8            printf("eight"); // print eight            break; // terminate        case 9: // if y=9            printf("nine"); // print nine            break; // terminate         }            a=a-y*x;            if (j>1)                printf("-");            else                 printf(" ");                 }     printf("\n");     return 0;}

十位数字一下都可以就是不知道为什么每次到十位数字就出错。我真的找不到问题,你有帮我看看问题在哪里吗?谢谢了。

0 0
原创粉丝点击