为什么在此程序中“ INVALID INPUT”不断出现[保持中]

问题描述 投票:-2回答:1

我不知道为什么即使我什么都没输入,“ INVALID INPUT”仍然不断出现?

#include <stdio.h>
#include <ctype.h>

int factorial(long long int b){
    if(b<=1){
        return 1;
    }
    else {
        return b*factorial(b-1);
    }
}
int main()
{
    long long int x,am=1;
    printf("Lets find the factorial!\n");
    while(am==1){
        printf("Enter a number: "); scanf("%lld",&x);
        printf("Factorial %lld = %lld\n",x,factorial(x));
        printf("Try again? Y/N\n");

        char con; 
        while(1){
            scanf("%c",&con);
            if(toupper(con) == 'Y'){
                break;
            } else if(toupper(con) == 'N'){
                am = 2;
                break;
            } else {
                // this keeps coming out
                printf("INVALID INPUT\n");
            }
        }
    }
    printf("Thank you for using!\n");
}
c function factorial
1个回答
0
投票

稍后再添加此行

© www.soinside.com 2019 - 2024. All rights reserved.