当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
进程间通信-互斥锁
ArcGIS license错误-15解决方法
Rust 中的 Cell 共享可变指针
【UDS统一诊断服务】一、诊断概述(1)— 诊断概述
C#【文件操作篇】按行读取txt文本
Robocode教程3——Robo机器剖析
渔网道路密度计算
Export the articles written in CSDN to PDF format
Static member
进程间通信的方式
P1586 solution to tetragonal theorem
爬取小米有品app商品数据
C#【文件操作篇】PDF文件和图片互相转换
深拷贝和浅拷贝的区别
Easy to use data set and open source network comparison website
PM2 deploy nuxt related commands
批量导出Arcgis属性表
For() loop parameter call order
【UDS统一诊断服务】四、诊断典型服务(4)— 在线编程功能单元(0x34-0x38)
函数的调用过程









