type person = record name: string; height: real; gender: string; end;
var group: array[1..5] of person; i: integer; tallestBoy: person; shortestGirl: person;
begin for i := 1 to 5 do begin writeln('Enter person ', i, ' details:'); write('Name: '); readln(group[i].name); write('Height: '); readln(group[i].height); write('Gender (M/F): '); readln(group[i].gender); end;
for i := 1 to 5 do begin if (group[i].gender = 'M') and ((tallestBoy.height = 0) or (group[i].height > tallestBoy.height)) then tallestBoy := group[i];
if (group[i].gender = 'F') and ((shortestGirl.height = 0) or (group[i].height < shortestGirl.height)) then shortestGirl := group[i];
end;
writeln('Tallest boy is ', tallestBoy.name, ' with height ', tallestBoy.height:0:2); writeln('Shortest girl is ', shortestGirl.name, ' with height ', shortestGirl.height:0:2);
program TallestAndShortest;
type
person = record
name: string;
height: real;
gender: string;
end;
var
group: array[1..5] of person;
i: integer;
tallestBoy: person;
shortestGirl: person;
begin
for i := 1 to 5 do
begin
writeln('Enter person ', i, ' details:');
write('Name: ');
readln(group[i].name);
write('Height: ');
readln(group[i].height);
write('Gender (M/F): ');
readln(group[i].gender);
end;
for i := 1 to 5 do
if (group[i].gender = 'F') and ((shortestGirl.height = 0) or (group[i].height < shortestGirl.height)) thenbegin
if (group[i].gender = 'M') and ((tallestBoy.height = 0) or (group[i].height > tallestBoy.height)) then
tallestBoy := group[i];
shortestGirl := group[i];
end;
writeln('Tallest boy is ', tallestBoy.name, ' with height ', tallestBoy.height:0:2);
writeln('Shortest girl is ', shortestGirl.name, ' with height ', shortestGirl.height:0:2);
end.