Код: Выделить всё
int g = 0;
int tries = 0;
// loop for the user to guess
while (g != numberToGuess) {
printf("Guess a number between 0 and 99: ");
cin >> g;
int t1 = 0, t2 = 0;
tries++;
if (g < numberToGuess) {
printf("The number is higher\n");
}
else if (g > numberToGuess) {
printf("The number is lower\n");
}
else if (g > 100) {
printf("Number has to be lower than 100. ");
}
else {
printf("You guess the correct number. You tried %d ", tries, tries == 1 ? "time" : "times");
break;
}
Подробнее здесь: https://stackoverflow.com/questions/737 ... value-once
Мобильная версия