
Проблема в том, что если я ввел пароль правильно то действия должны происходить дальше, по началу
так и было, но потом каким то образом, программа начала закрываться даже когда пароль правильный. PascalABC.NET Program Gamer; var key: string; name: string; Age: integer; Height: integer; Weight: integer; cartoons: string; begin writeln('Добро пожаловать! Для авторизования введите Ваше имя!'); writeln(''); readln(name); sleep(2000); writeln(name, ',', ' ', 'Введите Ваш административный пароль'); writeln(''); readln(key); if(key='wNei3wVrYH~gGNa') then writeln('Вы авторизовались как администратор!') else writeln('Вы ввели неправильно административный пароль!'); sleep(3000); begin Exit; writeln('Пройдите небольшой тест, затем результаты напишите на листочке!'); sleep(1000); writeln('How old are you?'); writeln(''); readln(Age); if(Age>15) then writeln('You"re an adult') else writeln('You"re not an adult'); sleep(1500); writeln('Tell me how tall are you?'); writeln(''); readln(Height); if(Height>30) then writeln('You"re a very small man!') else writeln('You"re already a tall man.'); sleep(2000); writeln('What is your weight?'); writeln(''); readln(Weight); if(Weight>100) then writeln('You"re a very fat person!') else writeln('You have the right weight!'); sleep(1500); writeln('What kind of cartoons do you like?'); writeln(''); readln(cartoons); sleep(2000); writeln(name, ' ', 'Все очень превосходно!'); sleep(1000); writeln('Ваше имя: ', ' ', name); writeln('Административный пароль: ', ' ', key); writeln('Возраст: ', ' ', Age); writeln('Рост: ', ' ', Height); writeln('Вес: ', ' ', Weight); writeln('Мультфильмы, которые нравятся: ', ' ', cartoons); sleep(30000); end; end.

Ответы на вопрос

Тут нет ничего удивительного.
sleep(3000);
begin
Exit;
Вот этот выход и срабатывает в любом случае.



There seems to be an issue in your PascalABC.NET code that causes the program to close even when the correct password is entered. The problem lies in the incorrect placement of the Exit
statement. The Exit
statement is currently placed before the code block where the rest of the program logic is located, causing the program to exit prematurely regardless of the password input.
To fix this issue, you need to remove the Exit;
statement from its current position and place it after the entire code block where the user is asked for information (age, height, weight, and cartoons) and the results are displayed.
Here's the corrected code:
pascalProgram Gamer; var key: string; name: string; Age: integer; Height: integer; Weight: integer; cartoons: string; begin writeln('Добро пожаловать! Для авторизования введите Ваше имя!'); writeln(''); readln(name); sleep(2000); writeln(name, ',', ' ', 'Введите Ваш административный пароль'); writeln(''); readln(key); if (key = 'wNei3wVrYH~gGNa') then writeln('Вы авторизовались как администратор!') else begin writeln('Вы ввели неправильно административный пароль!'); sleep(3000); Exit; // Exit the program if the password is incorrect end; // If the password is correct, continue with the rest of the program writeln('Пройдите небольшой тест, затем результаты напишите на листочке!'); sleep(1000); writeln('How old are you?'); writeln(''); readln(Age); if (Age > 15) then writeln('You"re an adult') else writeln('You"re not an adult'); sleep(1500); writeln('Tell me how tall are you?'); writeln(''); readln(Height); if (Height > 30) then writeln('You"re a very small man!') else writeln('You"re already a tall man.'); sleep(2000); writeln('What is your weight?'); writeln(''); readln(Weight); if (Weight > 100) then writeln('You"re a very fat person!') else writeln('You have the right weight!'); sleep(1500); writeln('What kind of cartoons do you like?'); writeln(''); readln(cartoons); sleep(2000); writeln(name, ' ', 'Все очень превосходно!'); sleep(1000); writeln('Ваше имя: ', ' ', name); writeln('Административный пароль: ', ' ', key); writeln('Возраст: ', ' ', Age); writeln('Рост: ', ' ', Height); writeln('Вес: ', ' ', Weight); writeln('Мультфильмы, которые нравятся: ', ' ', cartoons); sleep(30000); end.
Now, if the password is correct, the program will run as intended and continue to execute the rest of the code where it asks for user information and displays the results. If the password is incorrect, the program will display the corresponding message and then exit.


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili