#include<stdio.h>#include<stdlib.h>#include<time.h> void fun(int c ){ srand((unsigned)time(NULL)); int ret = rand() % 100 + 1; printf("請(qǐng)輸入一個(gè)數(shù)>"); while (1) { scanf("%d", &c); if (c == ret) { printf("正確\n"); break; } else if (c > ret) { printf("猜大了\n"); } else { printf("猜小了\n"); } }} void menu() { printf("********************\n"); printf("****游戲開(kāi)始********\n"); printf("********************\n"); printf("*****請(qǐng)選擇*********\n"); printf("********************\n"); printf("****1 游戲開(kāi)始******\n"); printf("********************\n"); printf("****2 游戲結(jié)束******\n"); printf("********************\n"); printf("********************\n"); }int main(){ int c = 0; int num = 0; int input = 0; while (1) { menu(); printf("請(qǐng)選擇\n"); scanf("%d", &input); switch (input) { case 1: printf("游戲開(kāi)始\n"); fun( num); break; { case 2: printf("游戲結(jié)束\n"); break; } } //break; } printf("%d", c); system("pause"); return 0;