程式碼:
#include <stdio.h> #include <time.h> int main() { srand(time(NULL)); int n=rand()%1000;//0~999 printf("Hi.Let's start the game!\n"); while (1) { int temp; printf("Enter one number(0~999): "); scanf_s("%d", &temp); if (temp == n) { printf("Congratulation! You win!\n"); break; } else if (temp > n) printf("This number is too big!\n"); else printf("This number is too small!\n"); printf("\n"); } return 0; }
沒有留言:
張貼留言