当前位置:网站首页>Figure guessing game
Figure guessing game
2022-04-23 06:36:00 【*Flowers bloom on the street】
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int rander()// Generate random numbers
{
time_t ts;
unsigned int n = time(&ts);// Acquisition time
srand(n);// Initialize random seed
int num = rand() % 100 + 1;// Random number range 1—100
return num;
}
int main()
{
int a = -1;
char opt = 'a';// choice
printf(" Please choose whether to start the game :Y(y)/N(n)\n");
scanf_s("%c", &opt,1);
while (opt == 'Y' || opt == 'y')
{
int num = rander();
int tmp = 0;// Mark whether to end the cycle
while (tmp != 1)
{
printf(" Please input your guess number :", &a);
scanf_s("%d", &a, 1);
if (a == num)
{
printf(" That's right \n");
tmp = 1;
break;
}
else if (a < num)
{
printf(" Guess what \n");
}
else if (a > num)
{
printf(" Guess big \n");
}
}
printf(" Please choose whether to continue the game :Y(y)/N(n)\n");
getchar();// Receive multiple input carriage returns
scanf_s("%c", &opt,1);
}
return 0;
}
版权声明
本文为[*Flowers bloom on the street]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230547207289.html
边栏推荐
猜你喜欢

Detailed arrangement of knowledge points of University probability theory and mathematical statistics

Robocode教程8——AdvancedRobot

【UDS统一诊断服务】四、诊断典型服务(4)— 在线编程功能单元(0x34-0x38)

For() loop parameter call order

如何安装jsonpath包

for()循环参数调用顺序

7-21日错题涉及知识点。

【UDS统一诊断服务】五、诊断应用示例:Flash Bootloader

【UDS统一诊断服务】四、诊断典型服务(3)— 读故障信息功能单元(存储数据传输功能单元)

非参数化相机畸变模型简介
随机推荐
几行代码教你爬取LOL皮肤图片
Cf515b drazil and his happy friends
gcc ,g++,gdb的安装
【UDS统一诊断服务】四、诊断典型服务(3)— 读故障信息功能单元(存储数据传输功能单元)
Vscode custom comments
C语言数组处理批量数据
Cf1427c the hard work of paparazzi
Excel打开超大csv格式数据
pyppeteer爬虫
Miscellaneous 1
Cross domain issues - allow origin header contains multiple values but only one is allowed
Log4j2跨线程打印traceId
声明为全局变量
Make your own small program
【UDS统一诊断服务】三、应用层协议(1)
【无标题】
Call procedure of function
GDB debugger installation and use
Robocode教程4——Robocode的游戏物理
Rust 中的 Cell 共享可变指针