当前位置:网站首页>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
边栏推荐
猜你喜欢
Basemap库绘制地图
基于Sentinel+Nacos 对Feign Client 动态添加默认熔断规则
【UDS统一诊断服务】(补充)五、ECU bootloader开发要点详解 (1)
Graduation project, viewing screenshots of epidemic psychological counseling system
Programmers can also write novels
scikit-learn sklearn 0.18 官方文档中文版
Explanation of the second I interval of 2020 Niuke summer multi school training camp
解决ArcGIS分区统计显示太多唯一值执行失败
Robocode教程3——Robo机器剖析
非参数化相机畸变模型简介
随机推荐
生成验证码
The waterfall waterfall flow of uview realizes single column and loads more
gcc ,g++,gdb的安装
队列解决约瑟夫问题
Rust的闭包类型(Fn, FnMut, FnOne的区别)
Record the installation and configuration of gestermer on TX2, and then use GST RTSP server
PM2 deploy nuxt related commands
【UDS统一诊断服务】三、应用层协议(2)
【UDS统一诊断服务】二、网络层协议(2)— 数据传输规则(单帧与多帧)
selenium+PhantomJS破解滑动验证2
Qthread simple test understanding
Rust:在线程池中共享变量
非参数化相机畸变模型简介
搭建openstack平台
静态成员
PM2 deploy nuxt project
多线程爬取马可波罗网供应商数据
爬虫效率提升方法
Log4j2跨线程打印traceId
Explanation of the second I interval of 2020 Niuke summer multi school training camp