void menu()
{ printf(" \n"); printf("Digital bomb \n"); printf(" \n"); printf(" 1.play 0.exit \n"); printf(" \n "); }
void game()//Guess the number
//1. Create a random value
//2. Then in this value
{ int ret = 0; int n = 0; ret = rand() % 100 + 1;//Create Numbers from 1 to 100 system("cls");//Clear screen while (1) { printf("Guess a number>:"); scanf("%d",&n); if (n > ret) { printf("The guess is too big\n"); } else if (n < ret) { printf("The guess is too small\n"); } else { printf("Crash, explode了\n"); break; } } printf("%d", ret); }
//Timestamp: current computer time - starting computer time ---- time is changing
//2023 - 01 - 17 10:33 : 57
//1970 - 01 - 01 0 :0 :0
int main( )//Guess the number game
//1. Set up the game menu
//2. Set up the number guessing game
//3.
{ srand((unsigned int)time(0));//Take a random value int eye = 0; do { menu(); printf("Please select >:"); scanf("%d", &eye); switch (eye) { case 1: { game(); break; } case 0: { //printf(" Loading game"); //Sleep(3600);
printf("Goodbye game");
break;
}
default:
printf("You made a mistake, please enter 0 or 1");
break;
}
} while (eye);
return 0;
}