Good day. Help solve the puzzle: the user is prompted to enter a number from 1 to 100 through (prompt), then the second user is asked to guess the given number (prompt), after which he either guesses or is asked to enter again, while saying more or less a number. After the withdrawal for how many attempts to guess. PSHelp please.

  • 2
    > Only not through the function. Fantasy. - Oleg
  • 3
    @FantomRed, According to the rules of the forum, questions should not be limited to solving or completing student assignments. Please clarify what you have done yourself and what did not work out. - VioLet
  • @FantomRed, here before you someone has already asked the same question. Only (as far as I remember) is worded worse. For your wording I advise you to guess the binary search. - avp

1 answer 1

Pseudocode:

write("Введите число: ") read(x); i = 0 tmp = x-1 while (tmp !== x) do write("Угадай число, ну же: ") read(tmp) if (tmp !==x) write("Неправильно, число ", (x < tmp) ? "больше" : "меньше", " чем нужно") i++ end write("Угадали за ", i, " попыток") 

On js write yourself

  • one
    Thank you for your help. That's why it’s not clear why they put the minuses, no, of course I understand that there are all very smart people where I am to you. I will try not to contact you again and advise everyone I know too. - FantomRed 5:59 pm
  • @FantomRed is just not there to do all the work for the person. - VioLet