#include <stdio.h> #include <time.h> #include <stdlib.h> int main() { int random = 0; int input = 0; int start = 1; while (start) { printf("*********************\n"); printf("**1 start 0.exit**\n"); printf("*********************\n"); printf("請選擇:>"); scanf("%d", &start); switch (start) { case 1: { srand((unsigned)time(NULL)); random = rand()%100; while (1) { printf("請輸入你猜的數:>"); scanf("%d", &input); if (input > random) { printf("猜大了\n"); } else if (input < random) { printf("猜的太小了\n"); } else { printf("你好厲害啊\n"); break; } } break; } case 0: { printf("感謝使用猜數字游戲,bye bye\n"); exit(0); break; } default: { break; } } return 0; }