ג. התוכנית בשפת פסקל
program Course(input,output);
const
Max=200;
type
MemberType = record
Age : integer;
Sex : char;
Month : integer;
end;
MemberArray = array[1..Max] of MemberType;
IntArray = array[1..12] of integer;
var
Members : MemberArray;
Birthdays, Boys , Girls :IntArray;
procedure GetInfo ( var Members : MemberArray);
var
I : integer;
begin
for I := 1 to Max do
begin
writeln;
readln(Members[I].Age);
readln(Members[I].Sex);
readln(Members[I].Month);
end;
end;
function Balance( Members : MemberArray ) : boolean;
var
I : integer;
Count:integer;
begin
Count := 0;
for I := 1 to Max do
begin
if members[I].age=18 then
if Members[I].Sex='b' then Count := Count+1
else Count := Count-1;
Balance := abs(Count)<=5;
end;
end;
procedure Init( var Birthdays:IntArray);
var
I : integer;
begin
for I := 1 to 12 do
Birthdays[I] := 0;
end;
procedure Birth (Members : MemberArray ; var Birthdays:IntArray );
var
I:integer;
begin
for I := 1 to Max do
Birthdays[Members[I].Month] := Birthdays[Members[I].Month]+1;
end;
procedure MinBirth (Birthdays : IntArray );
var
I , Min : integer;
begin
Min := Max;
for I := 1 to 12 do
if Birthdays[I]<Min then Min := Birthdays[I];
for I := 1 to 12 do
if Birthdays[I]=Min then writeln( I );
end;
procedure BirthBySex (Members : MemberArray; Sex:char ; var
Mem:IntArray );
var
I:integer;
begin
for I := 1 to Max do
if Members[I].Sex=Sex then
Mem[Members[I].Month] := Mem[Members[I].Month]+1;
end;
procedure MoreBoys ( Boys,Girls: IntArray );
var
I :integer;
begin
for I := 1 to 12 do
if Girls[I] > Boys[I] then writeln ( I );
end;
begin { main }
GetInfo ( Members);
writeln (Balance(Members));
Init(Birthdays);
Birth(Members,Birthdays);
MinBirth(Birthdays);
Init(Boys);
Init(Girls);
BirthBySex(Members,'b',Boys);
BirthBySex(Members,'g',Girls);
MoreBoys( Boys,Girls);
end.