{-- coding by Sabit Murzaliyev --}
program olimp;
const
max = 100;
type
TParticipant = record
LastName : string[20];
FirstName: string[15];
Class: 7..11;
Bal: integer;
end;
var
n, i, j, err, max_bal, winner: integer;
s: string;
Participants: array [1..max] of TParticipant;
Temp: TParticipant;
c, param: byte;
bOk: boolean;
begin
write('Input participant count: ');
readln(n);
writeln('Enter data of participants');
writeln('Format: Lastname Firstname class bal');
writeln;
for i:= 1 to n do
begin
repeat
bOk:= true;
param:= 0;
write(i,': ');
readln(s);
if length(s) < 6 then
bOk:= false
else
for j:= 2 to length(s) do
if (s[j] = ' ') and (s[j-1] <> ' ') then
inc(param);
if (param <> 3) then bOk:= false;
if s[length(s)] = ' ' then bOk:= false;
c:= pos(' ', s);
Temp.LastName:= copy(s, 1, c-1);
s:= copy(s, c+1, length(s)-c);
c:= pos(' ', s);
Temp.Firstname:= copy(s, 1, c-1);
s:= copy(s, c+1, length(s)-c);
c:= pos(' ', s);
val(copy(s, 1, c-1), Temp.Class, err);
s:= copy(s, c+1, length(s)-c);
val(s, Temp.Bal, err);
if bOk then
begin
writeln('ok');
Participants:= Temp;
end
else writeln('error');
until bOk;
end;
max_bal:= Participants[1].Bal;
winner:= 1;
for i:= 2 to n do
if (Participants.Bal >= max_bal) and (Participants.Bal <= 200) then
begin
if Participants.Bal = max_bal then inc(winner);
max_bal:= Participants.Bal;
end;
if winner = 1 then
begin
writeln('Winner');
for i:= 1 to n do
if Participants.Bal = max_bal then
writeln(Participants.Lastname +' '+ Participants.Firstname);
end
else
writeln('winners count: ', winner);
readln;
end.
[свернуть]