Написано и отлажено на FreePascal
program test;
uses
crt;
const
require = 18;
type
arr = array of byte;
fios= array of string;
var
phis, math, russ, eng, tot : arr;
fio : fios;
num: byte;
i, j, k : byte;
st, t : string;
val, key : byte;
p, m, r, f : byte;
begin
write('How many peoples: ');
readln(num);
writeln;
setLength(fio, num);
setLength(phis, num);
setLength(math, num);
setLength(russ, num);
setLength(eng, num);
setLength(tot, num);
for i:=0 to num-1 do
begin
writeln('People ', i+1);
write('F.I.O.: ');
readln(fio[i]);
write('Phis: ');
readln(phis[i]);
write('Math: ');
readln(math[i]);
write('Russ: ');
readln(russ[i]);
write('Eng: ');
readln(eng[i]);
tot[i] := phis[i]+math[i]+russ[i]+eng[i];
writeln;
end;
writeln;
writeln(' V E D O M O S T');
writeln('---------------------------------------------------------------');
writeln('| F. I. O. | Phis | Math | Russ | Eng | Total |');
writeln('---------------------------------------------------------------');
for i:=0 to num-1 do
begin
st := '| ' + fio[i];
j:= length(st);
if j<17 then<br> for k:=1 to 17-j do st:=st+' ';
st:=st+'|';
str(phis[i], t);
st := st + ' ' + t + ' |';
str(math[i], t);
st := st + ' ' + t + ' |';
str(russ[i], t);
st := st + ' ' + t + ' |';
str(eng[i], t);
st := st + ' ' + t + ' |';
str(tot[i], t);
st := st + ' ' + t + ' |';
writeln(st);
end;
writeln('---------------------------------------------------------------');
for i:=0 to num-1 do
begin
val:=tot[i];
st:=fio[i];
p:=phis[i];
m:=math[i];
r:=russ[i];
f:=eng[i];
key:=i;
for j:=i+1 to num-1 do
if tot[key] if key<>i then
begin
tot[i] := tot[key];
tot[key] := val;
fio[i] := fio[key];
fio[key] := st;
phis[i] := phis[key];
phis[key] := p;
math[i] := math[key];
math[key] := m;
russ[i] := russ[key];
russ[key] := r;
eng[i] := eng[key];
eng[key] := f;
end;
end;
writeln;
writeln(' Sorted vedomost by total balls');
writeln('---------------------------------------------------------------');
writeln('| F. I. O. | Phis | Math | Russ | Eng | Total |');
writeln('---------------------------------------------------------------');
for i:=0 to num-1 do
begin
st := '| ' + fio[i];
j:= length(st);
if j<17 then<br> for k:=1 to 17-j do st:=st+' ';
st:=st+'|';
str(phis[i], t);
st := st + ' ' + t + ' |';
str(math[i], t);
st := st + ' ' + t + ' |';
str(russ[i], t);
st := st + ' ' + t + ' |';
str(eng[i], t);
st := st + ' ' + t + ' |';
str(tot[i], t);
st := st + ' ' + t + ' |';
writeln(st);
end;
writeln('---------------------------------------------------------------');
writeln;
writeln(' Spisok postupifshih studentov');
writeln('---------------------------');
writeln('| F. I. O. | Total |');
writeln('---------------------------');
for i:=0 to num-1 do
begin
if tot[i] >= require then
begin
st := '| ' + fio[i];
j:= length(st);
if j<17 then<br> for k:=1 to 17-j do st:=st+' ';
st:=st+'|';
str(tot[i], t);
st := st + ' ' + t + ' |';
writeln(st);
writeln('---------------------------');
end;
end;
end.