C语言小游戏:猜数字
来源:互联网 发布:思迅会计软件 编辑:程序博客网 时间:2024/05/21 09:32
**给大家介绍一个小小的游戏代码,猜数字游戏。
`#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_SECURE_NO_WARNINGS 1#include <stdio.h>#include <math.h>#include <windows.h>#include <stdlib.h>#include <time.h>void menu(){ printf("*******************************\n"); printf("** 1.play 0.exit **\n"); printf("*******************************\n");}void game(){ int num = 0; int input = 0; num = rand()%100+1; while(1) { printf("请猜数字:>"); scanf("%d", &input); if(input == num) { printf("恭喜你,猜对了\n"); break; } else if(input>num) { printf("猜大了\n"); } else { printf("猜小了\n"); } }}int main(){ int input = 0; srand((unsigned int)time(NULL)); do { menu(); printf("请选择:>"); scanf("%d", &input); switch(input) { case 1: game(); break; case 0: printf("退出游戏\n"); break; default: printf("选择错误\n"); break; } } while(input); return 0;}
`**
感兴趣的朋友们可以玩玩消遣。
阅读全文
0 0
- c语言猜数字小游戏
- C语言猜数字小游戏
- 【C语言】猜数字小游戏
- C语言小游戏:猜数字
- c语言之猜数字的小游戏
- 猜数字小游戏[C语言][自制]
- 简单的C语言猜数字小游戏
- c语言:编写猜数字小游戏。
- C语言编写猜数字小游戏
- 用c语言编写猜数字小游戏
- C语言- 猜测数字小游戏
- 如何运用C语言制作猜数字小游戏?
- C语言小游戏之猜数字,三子棋游戏
- 用c语言实现的猜数字小游戏
- c语言猜数字小游戏(搞怪版)
- go语言猜数字小游戏
- Visual C#_ Framework.猜数字小游戏
- C语言实现的猜数字小游戏(主要是对于自定义函数的运用)
- webpack插件-html-webpack-plugin
- INSERT INTO SELECT 实例
- 链式队列实现迷宫寻径
- 沉浸式透明渐变
- sdnu1521手写堆排
- C语言小游戏:猜数字
- IST改进算法之Two-Step Iterative Shrinkage/Thresholding(TwIST)
- 2017/11/27学习笔记 Mysql基础
- 怎么把PHP中复选框选中的多个值写入到数据库中
- Couldn't save uncommitted changes,Tried to save uncommitted changes in stash before update,but faile
- linux C 进程结束 exit与_exit函数
- 以hive为例说明程序的三种使用方式
- [jzoj]3472. 【NOIP2013模拟联考8】匹配(match)(AC自动机+DP)
- 显示中文