编写一个程序,用于接受从终端输入的证书,提取并采用英语现实这个数的每一个数字。如输入932 应显示:
nine
three
two
下面是我的代码,不知道为什么输出的时候,只能输出一位,比如输入932,输出nine。
求大神指导~
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
int x,y,n,i,number;
NSLog(@"please input a number:");
scanf("%i",&x);
n=1;
i=1;
y=x;
while (y/10!=0)
{
y/=10;
n*=10;
i++;
}
while(i!=0)
{
number=x/n;
switch (number) {
case 0:
NSLog(@"zero");
break;
case 1:
NSLog(@"one");
break;
case 2:
NSLog(@"two");
break;
case 3:
NSLog(@"three");
break;
case 4:
NSLog(@"four");
break;
case 5:
NSLog(@"five");
break;
case 6:
NSLog(@"six");
break;
case 7:
NSLog(@"seven");
break;
case 8:
NSLog(@"eight");
break;
case 9:
NSLog(@"nigh");
break;
}
n/=10;
i--;
}
}
return 0;
}