Program otchet;
Uses crt;
Type zapis = record
a1,a2,a3,a4,a5,a6:string;
end;
Var otchet: array[0..50] of zapis; t: zapis;
YN:char; vsegoElem,i,j,k:integer; str1,str2:string;
Begin clrscr;
vsegoElem:=0;
repeat
write('nazvanie tovara '); readln(otchet[vsegoElem].a1);
write('kod tovara '); readln(otchet[vsegoElem].a2);
write('nazvanie magazina '); readln(otchet[vsegoElem].a3);
write('firma proizvoditelya '); readln(otchet[vsegoElem].a4);
write('cena za 1 ed. tovara '); readln(otchet[vsegoElem].a5);
write('kolichestvo tovara '); readln(otchet[vsegoElem].a6);
inc(vsegoElem);
write(#13,#10,'new tovar (y/n) '); readln(YN); write(#13,#10);
until YN<>'y';
for i:=1 to vsegoElem-1 do
for k:=0 to vsegoElem-i-1 do begin
str1:=otchet[k].a2; str2:=otchet[k+1].a2;
for j:=1 to length(str1) do
if (str1[j]>str2[j]) or (j>length(str2)) then begin
t:=otchet[k]; otchet[k]:=otchet[k+1]; otchet[k+1]:=t; break; end
else if str1[j]<str2[j] then break;
end;
write(#13,#10,'vivesti po nazvaniya = '); readln(str1); j:=length(str1);
for i:=0 to vsegoElem-1 do begin
if j<>length(otchet[i].a1) then continue;
str2:=otchet[i].a1;
for k:=1 to j do begin
if str1[k]<>str2[k] then break;
if k=j then writeln(otchet[i].a3);
end;
end;
readln;
end.
Сообщение отредактировано: JeFix -