Исправление bormant, (текущая версия) :
В сухом остатке:
const nmax=10; KeyBeg=15; KeyEnd=24;
type TLine = array [0..25] of Char;
var
a: array [1..nmax] of TLine;
t: TLine;
n, i, j, k, p: Integer;
begin
Assign(input,'in.txt'); Reset(input);
Assign(output,'result.txt'); Rewrite(output);
{n:=0;}
while (n<nmax) and not EoF do begin
Inc(n); ReadLn(a[n]); WriteLn(a[n]);
end;
for i:=2 to n do begin
t:=a[i]; j:=i-1;
while j>0 do begin
for k:=KeyBeg to KeyEnd do begin
p:=Ord(t[k])-Ord(a[j,k]);
if p<>0 then Break;
end;
if p<0 then begin
a[j+1]:=a[j]; Dec(j);
end else Break;
end;
a[j+1]:=t;
end;
WriteLn; WriteLn('Sorted:');
for i:=1 to n do WriteLn(a[i]);
Close(input); Close(output);
end.
Исходная версия bormant, :
В сухом остатке:
const nmax=10; KeyBeg=15; KeyEnd=24;
type TLine = array [0..25] of Char;
var
a: array [1..nmax] of TLine;
t: TLine;
n, i, j, k, p: Integer;
begin
Assign(input,'in.txt'); Reset(input);
Assign(output,'result.txt'); Rewrite(output);
{n:=0;}
while (n<nmax) and not EoF do begin
Inc(n); ReadLn(a[n]); WriteLn(a[n]);
end;
for i:=2 to n do begin
t:=a[i]; j:=i-1;
while (j>0) do begin
for k:=KeyBeg to KeyEnd do begin
p:=Ord(t[k])-Ord(a[j,k]);
if p<>0 then Break;
end;
if p<0 then begin
a[j+1]:=a[j]; Dec(j);
end else Break;
end;
a[j+1]:=t;
end;
WriteLn; WriteLn('Sorted:');
for i:=1 to n do WriteLn(a[i]);
Close(input); Close(output);
end.