如何在C中执行while循环

时间:2014-10-30 15:11:20

标签: c loops

 printf("Please type Y if you want us to compute the monthly Rate for new data and N otherwise: ");
scanf("%c",&ans);

while ((ans!='y') && (ans!='Y') && (ans!='n') && (ans!='N')){
        printf("Please type Y if you want us to compute the monthly Rate for new data and N otherwise: ");
        scanf("%c",&ans);}

if (ans == 'N' || ans == 'n'){
    printf("Thank you Please visit us again");}
else if (ans == 'Y' || ans == 'y')

执行此操作时,如果我输入n或y,它的工作方式是正确的,但是如果我输入的东西不是n或y,输出让我输入另一个值,而不是说它如果你想我们计算请输入Y每月新数据的比率和N否则:它说两次,我无法弄清楚为什么会说两次。

0 个答案:

没有答案