当前位置:网站首页>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;
}
边栏推荐
- 【小技巧】使用matlab GUI以对话框模式读取文件
- MySQL advanced SQL statement 2
- Wechat applet calculates the distance between the two places
- Demonstration description of integrated base scheme
- Handling of inconsistency between cursor and hinttext position in shutter textfield
- Vite: configure IP access
- go 函数
- Finally got byte offer. The 25-year-old inexperienced perception of software testing is written to you who are still confused
- regular expression
- Analysis of the overall design principle of Nacos configuration center (persistence, clustering, information synchronization)
猜你喜欢

Qt插件之Qt Designer插件实现

66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)

Target free or target specific: a simple and effective zero sample position detection comparative learning method

Installation et utilisation du lac bleu

Actual combat | use composite material 3 in application

How much can a job hopping increase? Today, I saw the ceiling of job hopping.

BGP experiment the next day

手撕——排序

How to model noise data? Hong Kong Baptist University's latest review paper on "label noise representation learning" comprehensively expounds the data, objective function and optimization strategy of

Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)
随机推荐
Li Kou interview question 02.08 Loop detection
What is 5g industrial wireless gateway? What functions can 5g industrial wireless gateway achieve?
Sorted out an ECS summer money saving secret, this time @ old users come and take it away
The original author is out! Faker. JS has been controlled by the community..
Actual combat | use composite material 3 in application
SQL: common SQL commands
Lei Jun wrote a blog when he was a programmer. It's awesome
Opencv learning example code 3.2.4 LUT
A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
[wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification
手撕——排序
Www 2022 | rethinking the knowledge map completion of graph convolution network
Go branch and loop
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
Installation and use of blue lake
Pytorch---使用Pytorch进行鸟类的预测
MySQL advanced SQL statement 2
Play with concurrency: draw a thread state transition diagram
Sword finger offer II 006 Sort the sum of two numbers in the array
蓝湖的安装及使用