#include <stdio.h>
#include <stdlib.h>
/*猜测商品价格小游戏*/
int main()
{
int price;
int guessprice;
int count=0;
srand(time(NULL));//随机函数
price=rand()%10000;//为了得出一个四位数
printf("%d",price);
for(;;count++)
{
printf("请输入商品价格:\n");
scanf("%d",&guessprice);
if(price>guessprice)
{
printf("小了!\n");
}
else if(price<guessprice)
{
printf("大了!\n");
}
else
{
printf("恭喜你,猜对了!\n");
count++;
break;
}
}
printf("你一共猜测了%d次\n",count);
if(count<=3)
{
printf("哇!你简直就是个天才!\n");
}
else
{
printf("你也太笨了吧!\n");
}
return 0;
}
猜测商品价格小游戏
最新推荐文章于 2023-09-12 09:56:44 发布