当前位置:网站首页>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;
}
边栏推荐
- Sorted out an ECS summer money saving secret, this time @ old users come and take it away
- Wechat applet map annotation
- The first game of the 12th Blue Bridge Cup single chip microcomputer provincial competition
- [Li Kou brush questions] 15 Sum of three numbers (double pointer); 17. Letter combination of phone number (recursive backtracking)
- [untitled]
- Feature Engineering: summary of common feature transformation methods
- The second game of the 12th provincial single chip microcomputer competition of the Blue Bridge Cup
- Qt插件之Qt Designer插件实现
- What is 5g industrial wireless gateway? What functions can 5g industrial wireless gateway achieve?
- Use of go package
猜你喜欢

Lei Jun wrote a blog when he was a programmer. It's awesome

Opencv learning example code 3.2.4 LUT

Homework in Chapter 3 of slam course of dark blue vision -- derivative application of T6 common functions

Finally got byte offer. The 25-year-old inexperienced perception of software testing is written to you who are still confused

Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)

《动手学深度学习》(二)-- 多层感知机

【leetcode】34. Find the first and last positions of elements in a sorted array

Lost a few hairs, and finally learned - graph traversal -dfs and BFS

2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee

What is 5g industrial wireless gateway? What functions can 5g industrial wireless gateway achieve?
随机推荐
Déchirure à la main - tri
C language: examples of logical operation and judgment selection structure
[tips] use Matlab GUI to read files in dialog mode
The first game of the 12th Blue Bridge Cup single chip microcomputer provincial competition
LxC limits the number of CPUs
软件测试人的第一个实战项目:web端(视频教程+文档+用例库)
The original author is out! Faker. JS has been controlled by the community..
FAQ | FAQ for building applications for large screen devices
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
66.qt quick-qml自定义日历组件(支持竖屏和横屏)
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
手撕——排序
L'avènement de l'ère 5G, une brève discussion sur la vie passée et présente des communications mobiles
如何解决在editor模式下 无法删除物体的问题
The second game of the 12th provincial single chip microcomputer competition of the Blue Bridge Cup
Jetpack之LiveData扩展MediatorLiveData
Visual slam Lecture 3 -- Lie groups and Lie Algebras
10 minutes to understand CMS garbage collector in JVM
【leetcode】34. Find the first and last positions of elements in a sorted array
[JS event -- event flow]