
Написать программу, ведущую учет очков, набранных каждой командой при игре в баскетбол. Количество
очков, полученных командами в ходе игры, может быть равно 1, 2 или 3. После окончания игры выдать итоговое сообщение и указать номер команды-победительницы. Окончание игры условно моделировать вводом количества очков, равного нулю. На паскаль

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




commands: array [1..2] of byte;
buf: string;
begin
writeln('Формат ввода: (№ комманды)(пробел)(очки)');
writeln('Например: 1 3');
writeln('№ О');
repeat
readln(buf);
if buf = '0' then break;
commands[integer.Parse(buf[1])] += byte.Parse(buf[3]);
until false;
writeln(String.Format('Команда {0} победила во счётом {1} очк.', commands[1] > commands[2] ? 1 : 2, max(commands[1], commands[2])));
end.



Program for Tracking Basketball Scores in Pascal
To create a program that tracks the scores of each team during a basketball game, we can use Pascal. The program will allow for the input of scores (1, 2, or 3 points) for each team and will display the final message and the number of the winning team when the game ends (signaled by entering 0 as the score).
Here's a simple Pascal program to achieve this:
```pascal program BasketballScores;
var team1Score, team2Score: integer;
begin team1Score := 0; team2Score := 0;
writeln('Welcome to the Basketball Score Tracker!');
repeat write('Enter the score for Team 1 (1, 2, or 3, 0 to end the game): '); readln(team1Score);
if (team1Score > 0) and (team1Score < 4) then begin write('Enter the score for Team 2 (1, 2, or 3, 0 to end the game): '); readln(team2Score);
if (team2Score > 0) and (team2Score < 4) then begin writeln('Current Score - Team 1: ', team1Score, ' Team 2: ', team2Score); end else if team2Score <> 0 then begin writeln('Invalid score for Team 2. Please enter a valid score (1, 2, or 3).'); end; end else if team1Score <> 0 then begin writeln('Invalid score for Team 1. Please enter a valid score (1, 2, or 3).'); end; until (team1Score = 0) or (team2Score = 0);
if team1Score > team2Score then writeln('Team 1 is the winner with ', team1Score, ' points!'); else if team2Score > team1Score then writeln('Team 2 is the winner with ', team2Score, ' points!') else writeln('It is a tie! Both teams scored ', team1Score, ' points.');
writeln('Thank you for using the Basketball Score Tracker!'); end. ```
This program initializes the scores for both teams to 0 and then prompts the user to input the scores for each team. It checks for valid inputs (1, 2, or 3) and continues until the game is ended by entering 0 as the score. After the game ends, it displays the final message and the winning team based on the scores entered.
Feel free to modify and expand this program to suit your specific needs!


Топ вопросов за вчера в категории Информатика







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