#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int a,b,c=0;
srand(time(NULL));
a=rand()%101;
do
{
printf("input the b:");
scanf("b=%d\n",&b);
c++;
if(a>b) printf("wrong,too small\n");
else if(a<b) printf("wrong,too big\n");
else printf("right!\n");
}while(a=b && c<10);
printf("c!=%d",c);
return 0;
}
c语言中编写猜数游戏时直接使猜的次数为十并结束
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
想上天的狗 2021-10-17 21:03关注#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { int a,b,c=0; srand(time(NULL)); a=rand()%101; printf("%d\n",a); do { printf("input the b:"); scanf("%d",&b); c++; if(a>b) printf("wrong,too small\n"); else if(a<b) printf("wrong,too big\n"); else printf("right!\n"); }while(a=b && c<10); printf("c!=%d",c); return 0; }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报