#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { int num; srand((unsigned)time(NULL)); int ret=rand()%100+1; while(1) { printf("請輸入一個數字>>\n"); scanf("%d",&num); if(num>ret) printf("猜大了!"); if(num<ret) printf("猜小了!"); if(num==ret) { printf("恭喜你答對了!"); break; } } return 0; }