大神们,快来帮帮忙

2024-11-04 11:27:10
推荐回答(3个)
回答1:

参考代码如下:
#include
void main(void)
{
int datain;
int remains=21;
printf("Here are 21 matches,you and me pick one to four of then in turn,now you first!\n");

while(remains)
{
printf("Pls input the number you want to pick(1 to 4): ");
scanf("%d",&datain);
if(datain<1||datain>4)
{
printf("Wrong number,Pls reinput!\n\n");
}
else
{
printf("then computer will get %d.\n"5-remains);
remains-=5;
printf("now remains %d.\n",remains);
if(remains==1)
{
printf("\nNow you have to get the last one,\nso th ecomputer is win !!\n");
remains=0;/*quit the while() loop*/
}
}
}
return;
}

回答2:

好的啊!

回答3: