ios简单问题,求大神回答。。
阿神
阿神 2017-04-17 17:17:16
0
5
380

编写一个程序,用于接受从终端输入的证书,提取并采用英语现实这个数的每一个数字。如输入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;

}

阿神
阿神

闭关修行中......

모든 응답(5)
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!