标签:c
#include <stdio.h> #include <stdlib.h> #include <time.h> void game() { int input = 0; printf("欢迎使用猜数字游戏\n"); srand((unsigned int)time(NULL)); int ret = rand() % 100; do { printf("请输入你猜的数字:>"); scanf_s("%d", &input); if (input > ret) { printf("您猜得太大了\n"); } else if (input < ret) { printf("您猜得太小了\n"); } else { printf("恭喜你猜对了\n"); break; } } while (1); } void menu() { printf("************************\n"); printf("**** 1.开始游戏 ********\n"); printf("**** 0.退出游戏 ********\n"); printf("************************\n"); } int main() { int choice = 1; while (choice) { menu(); printf("请选择:>"); scanf_s("%d", &choice); switch (choice) { case 1: game(); break; default: break; } } system("pause"); return 0; }
本文出自 “Vs吕小布” 博客,请务必保留此出处http://survive.blog.51cto.com/10728490/1702474
标签:c
原文地址:http://survive.blog.51cto.com/10728490/1702474