您的位置:首页 > 其它

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

2014-02-19 12:12 197 查看
#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;
}


十位数字一下都可以就是不知道为什么每次到十位数字就出错。我真的找不到问题,你有帮我看看问题在哪里吗?谢谢了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐