Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
10
Добавлен:
17.04.2013
Размер:
3.23 Кб
Скачать
program laba5_var16;
uses crt;
const n=20; { ЊЂЉ‘€ЊЂ‹њЌЋ… ЉЋ‹-‚Ћ ‡ЂЏ€‘…‰ }
datapath = 'datafile.txt';
resultpath = 'resfile.txt';

type infa = record
fam,name,otch:string;
end;
var fresult,fdata:text;
i,j,k,line,max,poz,al,max_value:integer;
datum:array[1..n] of infa;
q,control:array [1..n] of integer;
ch:char;
alr:infa;
begin
clrscr;
assign(fdata,datapath);
{$I-}
reset(fdata);
{$I+}
if ioresult<>0 then
begin
textcolor(red);
writeln('Alert! File not exist!');
readln;
halt;
end;
assign(fresult,resultpath);
rewrite(fresult);
line:=0;
close(fdata);
reset(fdata);
line:=0;
for i:=1 to n do control[i]:=0;
for i:=1 to n do
if not eof(fdata) then
begin
inc(line);
with datum[i] do
begin
while ch<>' ' do
begin
read(fdata,ch);
if ch='#' then readln(fdata)
else fam:=fam+ch;
end;
while ch<>' ' do
begin
read(fdata,ch);
name:=name+ch;
end;
while not eoln(fdata) do
begin
read(fdata,ch);
otch:=otch+ch;
end;
readln(fdata);
end;
end;
for i:=1 to line do
begin
q[i]:=1;
for j:=i+1 to line do
begin
if datum[i].fam=datum[j].fam then
begin
inc(q[i]);
control[j]:=1;
end;
end;
end;
{for i:=1 to line do write(q[i],'=',control[i],' ');}
writeln;
for i:=1 to line do
begin
max_value:=0;
for j:=1 to line do
begin
if q[j]>max_value then
begin
max:=j;
max_value:=q[j];
end;
end;
if control[max]=0 then
begin
{writeln('______________________________________________');}
with datum[max] do
writeln(fresult,fam,' ',name,' ',otch,' д ¬Ё«Ёп ўбваҐз « бм ',q[max],' а §.');
end;
q[max]:=0;
end;
{for i:=1 to line do write(q[i],' ');}
writeln;
close(fdata);
close(fresult);

readln;
end.
Соседние файлы в папке VAR16