Có ai chỉ em làm sao để mỗi khi mình chọn mode để chơi, chọn có tiếp tục chơi hay không,… những dòng đó sẽ biến mất
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int so = 0, sobimat = 0, guesstime = 0, cont = 1, mode, lv;
// the game's highest and lowest numbers
while(cont != 2) {
printf("Please choose a mode to play:\n==1.Single Player==\n==2.Multi Player \n");
scanf("%d", &mode);
int max = 100, min = 0;
// Create a random number
if(mode == 1) {
// Single Player Mode
printf("Please choose a level:\n1.100 numbers\n2. 200 numbers\n3.300 numbers\n");
do {
scanf("%d", &lv);// Choose the level
//Maximum values for each level
if(lv == 1)
max = max, min = min;
else if(lv == 2)
max += 100, min = min; // Max = 200
else if(lv == 3)
max += 200, min = min; // Max = 300
else //if the *beep* player does not choose 1 of 3 levels above
printf("please choose level from 1 to 3");
} while (lv != 1 && lv != 2 && lv != 3);
srand(time(NULL));
sobimat = (rand() % (max - min + 1) + min);
} else if(mode == 2) {
printf("Manager please choose a random number (don't let the player know)\n");
scanf("%d", &sobimat);
}
// game play
do {
printf("Choose a number: ");
scanf("%d", &so);
guesstime++;
if(so < sobimat)
printf("Greater\n");
else if (so > sobimat)
printf("Lower\n");
else {
printf("That's it, you found it after %d time(s) guessing\n\n", guesstime);
guesstime = 0;
}
} while(so != sobimat);
printf("Do you want to play another game?\n");
printf("1.Yes\n2.No\n");
scanf("%d", &cont);
}
getch();
return 0;
}