当前位置:网站首页>Guess numbers + random numbers
Guess numbers + random numbers
2022-07-22 11:30:00 【p29949】
#include<stdio.h>
// The computer randomly generates a 1~100 Number between
// Guess the number
// If you guess small , Tell me it's too small
// If you guess big , Tell me you guessed big
// If you guessed right , Tell me you guessed right
#include <stdlib.h>
#include <time.h>
void menu()
{
printf("*********************************\n");
printf("********** 1. play ************\n");
printf("********** 0. exit ************\n");
printf("*********************************\n");
}
//rand Function can generate random numbers
// Return to one 0~RAND_MAX(32767)
void game()
{
int guess = 0;
//1. Generate random number
int ret = rand()%100+1;//0~99-->1~100
//printf("%d\n", ret);
//2. Guess the number
while (1)
{
printf(" Please guess the number :>");
scanf("%d", &guess);
if (guess < ret)
{
printf(" Guess a little \n");
}
else if (guess > ret)
{
printf(" Guess the \n");
}
else
{
printf(" congratulations , Guessed it \n");
break;
}
}
}
int main()
{
int input = 0;
// Set the generator of random numbers
srand((unsigned int)time(NULL));
do
{
menu();
printf(" Please select :>");
scanf("%d", &input);
switch (input)
{
case 1:
game();
break;
case 0:
printf(" Quit the game \n");
break;
default:
printf(" Wrong choice , To choose !\n");
break;
}
} while (input);
return 0;
}
边栏推荐
- Using virtual to implement hooks in solidity
- Is the account of flush safe? How much is the Commission for opening an account at CITIC Securities
- composer.json 常用配置解释
- Illustrate the beginning of NLP transfer learning by Bert, Elmo, etc
- What is causal deep learning? Deepmind's latest icml2022 "causality and deep learning: synergy, challenges and the future" tutorial
- (pc+wap) dream weaving template protective mask website
- AcWing 1124. 骑马修栅栏 题解(欧拉回路)
- AcWing 1184. 欧拉回路 题解(欧拉回路)
- The air conditioner in no man's land has poor refrigeration
- 敲黑板!Kubernetes 架构核心知识点就这么多
猜你喜欢
Recommended reading: how can testers get familiar with new businesses quickly?
《Multiple UAV exploration of an unknown region》翻译
imdecode、imencode、.tofile、fromfile 读取并保存 & 中文路径的中文名称的文件 & 一步一步解析并对比函数的结果
(PC+WAP)织梦模板情感资讯类网站
systemd 管理 blackbox-exporter
BGP的基本配置
Value and technical thinking of vectorization engine for HTAP
ADVANCE.AI:目前进入拉美地区的中国企业还较少,值得探索
Creation and call of stored procedure based on Oracle Database
systemd 管理 redis-exporter linux
随机推荐
Introduction to nodes
AcWing 1184. Euler circuit problem solving (Euler circuit)
[red team] att & CK - active scanning
[solution]vscode code code auto wrap bug without completion of input
Paste in ckeditor does not work (your browser does not support pasting through the toolbar or right-click menu, please press ctrl+v to paste)
你为什么会做测试/开发程序员?各路伙伴描述......
About BOM update of SAP apo rpmcall specified production order
Manual encapsulation object deep copy method
OSPF comprehensive experiment
SYSTEMd management process exporter
基于torchvision对模型最后几层进行微调,用于训练自己的数据
标签平滑(LabelSmoothing)介绍与代码实现
systemd 管理 process-exporter
基于PyTorch深度学习遥感影像地物分类与目标检测、分割及遥感影像问题深度学习优化
MySQL Varchar前缀索引的一个细节
BGP border gateway protocol
composer. JSON common configuration explanation
论文分享目标检测、图像分割、监督学习等
Time magazine's blockbuster cover: the meta universe era will change the world
OSPF综合实验