当前位置:网站首页>C language guessing game and trickery game
C language guessing game and trickery game
2022-04-23 00:58:00 【A monster that doesn't like fish】
Guess the number game to achieve // Let the computer generate a random number (1~100)
#include <time.h>
#include <stdlib.h>
void menu()
{
printf("******************************\n");
printf("********** 1.play **********\n");
printf("********** 2.exit **********\n");
printf("******************************\n");
}
void game()
{
//1、 Generate random number
int ret = rand()%100;// Functions that generate random numbers This function generates 0~RAND_MAX(32767) Number between , model 100 It will only be generated in the future 0~99 Again +1 Namely 1~100
printf("%d\n", ret);
//2、 Guess the number
int guess = 0;
printf(" Please guess the number :>");
scanf("%d", &guess);
while (1)
{
if (guess < ret)
{
printf(" Guess a little \n");
}
else if (guess > ret)
{
printf(" Guess the \n");
}
else
{
printf(" congratulations ! That's right !\n");
break;
}
}
}
int main()
{
srand((unsigned int)time(NULL));
// without srand This function Each time the same set of random numbers is generated
//srand Corresponding <stdlib.h> time Corresponding <time.h>
// If you use a constant in parentheses Then the same set of numbers will always be generated So you need a random number to start
// Time is the best random number —> Time stamp : Each time can correspond to a timestamp , It's a difference from the start time of the computer , The unit is in seconds
// As long as time is changing , The timestamp is changing Use time Function to generate timestamp
// time The function requires that the parameter we pass in is a pointer , If we don't want to use parameters We can use a null pointer NULL
//time The function returns an integer , typedef long long _64time_t
//srand What needs to be passed in is a unsigned int The type of What we need to do at this time is to cast
int input = 0;
do
{
menu();
printf(" Please select :>");
scanf("%d", &input);
switch (input)
{
case 1:
// Encapsulate the game here
game();
break;
case 0:
printf(" Quit the game \n");
break;
default:
printf(" Wrong choice , To choose !\n");
break;
}
} while (input);
return 0;
}
Let a friend's computer execute the shutdown program
// Shutdown Sequence
//1、 When the computer runs 1 Shut down in minutes
//2、 If input : I am a pig , Just cancel the shutdown
#include <string.h>
int main()
{
// stay Windows Of cmd Inside Input shutdown -s -t 60 (-s To shut down -s Shut down for a set time 60 by 60 Shut down in seconds ) Input shutdown -a You can cancel the shutdown
// How to execute system commands ? Use system function
char input[20] = {
0 };
system("shutdown -s -t 60");
again:
printf(" Please note that , Your computer is 60 Power off in seconds , If input : I am a pig , Just cancel the shutdown \n");
scanf("%s", input);
if (strcmp(input, " I am a pig ") == 0)
{
system("shutdown -a");
}
else
{
goto again;
}
return 0;
}
How to realize... Through files ?


After running the program again , There will be... Next to the folder where the project is stored release Folder , The inside exe Extract the execution file and send it to your friends
版权声明
本文为[A monster that doesn't like fish]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221110157130.html
边栏推荐
- BUUCTF 隐藏的钥匙
- Buuctf missing through time and space
- 如何成为真正的数字化企业,锐捷网络发布数字原力觉醒计划
- Thingskit Internet of things platform
- Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
- Fault analysis | federated storage engine table causes the monitoring thread to be in the opening table state
- GPT general timer analysis and configuration process of imx6ull bare metal development
- 软件测试神仙文档,连阿里面试官都说太详细了,搞懂这些直接是P7级
- Amazon Aurora's ability to read and write: shardingsphere proxy
- Detailed explanation of Milvus 2.0 quality assurance system
猜你喜欢

Yunrong technology joined the dragon dragon dragon community to help the digital transformation of the financial industry

Xamarin effect Chapter 22 recording effect

Earth day collection: Microsoft and Intel invite you to get the green Ambassador badge and give you negative carbon emission!

Thingskit Internet of things platform

flask项目跨域拦截处理以及dbm数据库学习【包头文创网站开发】

IMX6ULL裸机开发之GPT通用定时器分析及配置过程

Research and application of Acrel-5000 building energy consumption monitoring system in Xixian Airport Garden Project

Application of safe electricity management platform in Jingbian Museum safe electricity management system

What is tooljet and how about it—— Evaluation of low code development platform

What is the lifecycle of automated testing?
随机推荐
Essay 8: error in readpng (paste (location, "/", pattern. Type [i], ". PNG", Sep = "): unable to open C:/
Multi surveyor Xiao sir, Gongshu campus, Hangzhou_ Senior gold medal lecturer_ Resume practice
Ethtool process of viewing network card statistics
Multi surveyor Xiao sir, Gongshu campus, Hangzhou_ Senior gold medal lecturer_ Resume making explanation
Enterprises choose to privatize the deployment of IM instant messaging software to fully protect information security!
为企业出海“搭桥”,汇量科技靠什么出圈?
Processus d'analyse et de configuration du matériel IIC pour le développement de la machine nue imx6ull
Acrel-2000型电力监控系统在兴庆坊新兴广场配电所配电回路用电的实时监控和管理
Lightly: a new generation of go IDE
Open WebRTC Toolkit(OWT) Server User Guide
Ifconfig how to get the statistics of network card
IMX6ULL裸机开发之配置eLCDIF点亮RGB液晶屏分析及配置过程
DCB“一哥”先瑞达,靠什么拉升价值曲线?
Amazon Aurora's ability to read and write: shardingsphere proxy
How does zhiting connect Xiaomi smart speakers?
[HCTF 2018]admin
Buuctf missing through time and space
Elk setup (IV): monitor MySQL slow query and error log
What is the lifecycle of automated testing?
Hardware IIC analysis and configuration process of imx6ull bare metal development