码迷,mamicode.com
首页 > 其他好文 > 详细

【积累】Count on a Tree

时间:2020-08-07 22:58:41      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:sig   ++   lin   期望   操作   admin   names   使用   dep   

#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <math.h> #include <Windows.h> #include <stdlib.h> #include <time.h> int zhi = 100; void shezhi() { printf("请输入你要猜数最大是多少(默认100)\n"); scanf("%d", &zhi); printf("最大值修改为%d\n", zhi); } void mune() { printf("=====================================\n"); printf("===== 1.开始 2.设置 0.退出 =====\n"); printf("=====================================\n"); } void game() { int num1 = 0; int num2 = 0; int i = 10; num1 = rand() % zhi + 1; while (1) { printf("请猜数字:>\n"); scanf("%d", &num2); if (num2 > num1) { i--; printf("你输入的太大了,你还有%d次机会\n",i); } else if (num2<num1) { i--; printf("你输入的太小了,你还有%d次机会\n",i); } else { printf("恭喜你!猜对了\n"); Sleep(1000); system("cls"); printf("=====================================\n"); printf("===== 恭喜你!猜对了! 答案是%d =====\n",num2); printf("=====================================\n"); Sleep(1000); system("cls"); break; } if (i == 0) { printf("游戏结束!正确答案是%d\n", num1); Sleep(1000); system("cls"); break; } } } int main() { int input = 0; srand((unsigned int)time(NULL)); do { mune(); printf("请选择:>"); scanf("%d", &input); switch (input) { case 1: Sleep(500); system("cls"); printf("=====================================\n"); printf("===== 游 戏 开 始 =====\n"); printf("=====================================\n"); game(); break; case 0: Sleep(500); system("cls"); printf("=====================================\n"); printf("===== 游 戏 结 束 =====\n"); printf("=====================================\n"); break; case 2: shezhi(); break; default: printf("重新选择\n"); Sleep(500); system("cls"); break; } } while (input); return 0; }

【积累】Count on a Tree

标签:sig   ++   lin   期望   操作   admin   names   使用   dep   

原文地址:https://www.cnblogs.com/kkkek/p/13455352.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!