uses crt;
type congnhan = record
tuoi: integer;
luong: integer;
dd : boolean;
end;
var
CN: array[1..100] of congnhan;
x,y,sohieu,i,n,moc,j: integer;
tuoi,tong,dem:array[1..100] of integer;
procedure init;
begin
clrscr;
y:=1;
write(' n = '); readln(n);
for i:=1 to n do
begin
y:=y+2;
x:=x+2;
write(' Tuoi cua cong nhan thu ',i,' : tuoi ');
gotoxy(29,x);
readln(CN[i].tuoi);
write(' Luong cua cong nhan thu ',i,' : VND');
gotoxy(32,y);
readln(CN[i].luong);
CN[i].dd:=true;
end;
end;
procedure processing;
begin
for j:=1 to n do
if CN[j].dd=true then
begin
sohieu:=sohieu+1;
moc:=CN[j].tuoi;
for i:=j to n do
if CN[i].tuoi=moc then
begin
CN[i].dd:=false;
tuoi[sohieu]:=moc;
dem[sohieu]:=dem[sohieu] +1;
tong[sohieu]:=tong[sohieu]+CN[i].luong;
end;
end;
end;
procedure print;
begin
for i:=1 to sohieu do
writeln(tuoi[i] ,' tuoi co muc luong trung binh : ',tong[i]/dem[i]:6:1);
end;
BEGIN
init;
processing;
print;
readln;
END.