当前位置:网站首页>C语言猜数字游戏
C语言猜数字游戏
2022-07-02 04:08:00 【开飞机的贝塔儿】
猜数字游戏(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; //生成随机数1-100
while (1)
{
printf("猜数->");
scanf("%d", &guess);
if (guess > ret)
printf("猜大了\n");
else if (guess < ret)
printf("猜小了\n");
else
{
printf("正确\n");
break;
}
}
}
int main()
{
int input;
do
{
srand((unsigned int)time(NULL)); //时间戳,随机起点的设计
menu();
printf("是否游戏:");
scanf("%d",&input);
switch (input)
{
case 1:
game();
break;
case 0:
printf("退出游戏!!!\n");
break;
default:
printf("输入有误,重新输入:\n");
break;
}
} while (input);
return 0;
}
边栏推荐
- Actual combat | use composite material 3 in application
- The original author is out! Faker. JS has been controlled by the community..
- XSS prevention
- Target free or target specific: a simple and effective zero sample position detection comparative learning method
- 云服务器的安全设置常识
- 如何解决在editor模式下 无法删除物体的问题
- Welcome the winter vacation multi school league game 2 partial solution (B, C, D, F, G, H)
- 10 minutes to understand CMS garbage collector in JVM
- WPViewPDF Delphi 和 .NET 的 PDF 查看组件
- Okcc why is cloud call center better than traditional call center?
猜你喜欢

毕设-基于SSM电影院购票系统

Suggestions on settlement solution of u standard contract position explosion

【c语言】基础篇学习笔记

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

QT designer plug-in implementation of QT plug-in

Li Kou interview question 02.08 Loop detection

Raspberry pie GPIO pin controls traffic light and buzzer
![[JS event -- event flow]](/img/fe/199890b082845f68b65f25056e6f29.jpg)
[JS event -- event flow]

The 5th Blue Bridge Cup single chip microcomputer provincial competition

Realizing deep learning framework from zero -- Introduction to neural network
随机推荐
L'avènement de l'ère 5G, une brève discussion sur la vie passée et présente des communications mobiles
office_ Delete the last page of word (the seemingly blank page)
Installation et utilisation du lac bleu
Handling of inconsistency between cursor and hinttext position in shutter textfield
[untitled]
Is the product of cancer prevention medical insurance safe?
Which product of anti-cancer insurance is better?
5G时代全面到来,浅谈移动通信的前世今生
MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
Go language introduction
go 函数
Influence of air resistance on the trajectory of table tennis
Suggestions on settlement solution of u standard contract position explosion
The first game of the 11th provincial single chip microcomputer competition of the Blue Bridge Cup
Lei Jun wrote a blog when he was a programmer. It's awesome
Realizing deep learning framework from zero -- Introduction to neural network
Wpviewpdf Delphi and Net PDF viewing component
Finally got byte offer. The 25-year-old inexperienced perception of software testing is written to you who are still confused
Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf
【leetcode】74. Search 2D matrix