当前位置:网站首页>C language guessing numbers game
C language guessing numbers game
2022-07-02 04:09:00 【Beta flying a plane】
Guess the number game (1-100)
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
void menu()
{
printf("###########################\n");
printf("######1.play 0.exit######\n");
printf("###########################\n");
}
void game()
{
int ret;
int guess;
ret=rand() % 100 + 1; // Generate random number 1-100
while (1)
{
printf(" Guess the number ->");
scanf("%d", &guess);
if (guess > ret)
printf(" Guess the \n");
else if (guess < ret)
printf(" Guess a little \n");
else
{
printf(" correct \n");
break;
}
}
}
int main()
{
int input;
do
{
srand((unsigned int)time(NULL)); // Time stamp , Design of random starting point
menu();
printf(" Game or not :");
scanf("%d",&input);
switch (input)
{
case 1:
game();
break;
case 0:
printf(" Quit the game !!!\n");
break;
default:
printf(" Incorrect input , Re input :\n");
break;
}
} while (input);
return 0;
}
边栏推荐
- Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
- 【c语言】基础篇学习笔记
- Raspberry pie GPIO pin controls traffic light and buzzer
- Pytorch---使用Pytorch进行图像定位
- Installation et utilisation du lac bleu
- Wechat applet JWT login issue token
- The 10th Blue Bridge Cup single chip microcomputer provincial competition
- How much is the tuition fee of SCM training class? How long is the study time?
- Handling of inconsistency between cursor and hinttext position in shutter textfield
- Recently, the weather has been extremely hot, so collect the weather data of Beijing, Shanghai, Guangzhou and Shenzhen last year, and make a visual map
猜你喜欢
随机推荐
Visual slam Lecture 3 -- Lie groups and Lie Algebras
Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000
【leetcode】34. Find the first and last positions of elements in a sorted array
蓝湖的安装及使用
[untitled]
go 语言命名规范
Www2022 | know your way back: self training method of graph neural network under distribution and migration
Go branch and loop
SQL:常用的 SQL 命令
【无线图传】基于FPGA的简易无线图像传输系统verilog开发,matlab辅助验证
go 分支与循环
Yolov5网络修改教程(将backbone修改为EfficientNet、MobileNet3、RegNet等)
手撕——排序
Dare to go out for an interview without learning some distributed technology?
Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
go 函数
Pytorch---使用Pytorch进行鸟类的预测
Bitmap principle code record
BGP experiment the next day
[personnel density detection] matlab simulation of personnel density detection based on morphological processing and GRNN network