C语言实现益智小游戏1

来源:互联网 时间:1970-01-01


include <stdio.h>#include <stdlib.h>#include <time.h>void print_menu(){ printf("**********************/n"); printf("******* 1.start ******/n"); printf("******* 0. exit ******/n"); printf("**********************/n");}int main(){ int input = 1; printf("欢迎使用猜数字游戏/n"); while (input) { print_menu(); printf("请选择>"); scanf("%d", &input); switch (input) { case 1: { int n = 0; int ch = 0; srand((unsigned int)time(NULL)); n = rand() % 101; while (1) { printf("请猜一个(0-100)直接的数/n"); scanf("%d", &ch); if (ch > n) { printf("你猜大了/n"); } else if (ch <n) { printf("你猜小了/n"); } else { printf("恭喜你,猜对了/n"); break; } } break; } default: printf("游戏退出/n"); break; } } system("pause"); return 0;}

 



相关阅读:
Top