#include
#include
#include
#include
int main()
{
{
printf("********************************\n I want to play a game with you\n********************************");
}
int c;
printf("\nChoose your Rank LV1~LV3:");
scanf_s("%d", &c);
printf("\nYou have 3 chances");
int a, b;
srand(time(NULL));
if (c == 1)
{
a = 1 + (rand() % 10); //get a number from 1~10//
}
if (c == 2)
{
a = 1 + (rand() % 100); // get a number from 1~100//
}
if (c == 3)
{
a = 1 + (rand() % 1000); //get a number from 1~1000//
}
int n = 0;
while (a && n++ < 3)
{
printf("\nint a number:");
scanf_s("%d", &b);
if (a == b)
{
printf("good job\n");
break;
}
if (n != 3)
{
if (b > a)
printf("try a smaller number");
if (b < a)
printf("try a bigger number");
}
}
getchar();
return 0;
}
C语言 做了一个猜数游戏,如何在3次失败以后显示正确的数字printf应该加在哪里?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- threenewbee 2016-05-25 03:20关注
printf("正确数字是%d", a);
getchar();本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥65 永磁型步进电机PID算法
- ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
- ¥88 找成都本地经验丰富懂小程序开发的技术大咖
- ¥15 如何处理复杂数据表格的除法运算
- ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
- ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
- ¥15 latex怎么处理论文引理引用参考文献
- ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
- ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
- ¥15 乘性高斯噪声在深度学习网络中的应用