UNIX Free Pascal


         

,


close(f1);

close(f);

end.

 

13.5. , .

Program Tabs;

var

f1,f2:Text;

sin,sou:string;

i:Byte;

CheckSpaces:Boolean;

SetTab:Boolean;

begin

if ParamCount<2 then

begin

Writeln('Wrong parameters');

Writeln('Format: ./task <inputfile> <outputfile>');

Halt(1);

end;

Assign(f1,Paramstr(1));

Assign(f2,Paramstr(2));

Reset(f1);

Rewrite(f2);

While Not(eof(f1)) do

begin

Readln(f1,sin);

CheckSpaces:=False;

SetTab:=False;

sou:='';

For i:=1 to Ord(sin[0]) do

if (sin[i]=' ')and(not CheckSpaces) then begin CheckSpaces:=True;sou:=sou+' ';end

else if not(sin[i]=' ')then begin sou:=sou+sin[i]; CheckSpaces:= False;SetTab:=False;end

else if (sin[i]=' ')and(CheckSpaces)and(not SetTab) then begin sou[ord(sou[0])]:=#9;SetTab:=True;end

else if (not (sin[i]=' '))and(CheckSpaces)and (SetTab) then

begin

sou:=sou+sin[i];

SetTab:=False;

end;

Writeln(f2,sou);

end;

Close(f1);

Close(f2);

end.

 

13.6. .

uses strings;

type

achar=array [0..255] of char;

mas=array [1..1] of achar;

var s:achar;

t:text;

a:^mas;

n,i,j,k:byte;

begin

if ParamCount<>2 then

begin

Writeln('Error!!!');

Writeln('Format: ./task <sourcefile> <destfile>');

Halt(1);

end;

s:=ParamStr(1);

assign(t,s);

reset(t);

k:=0;



while not eof(t) do

begin

readln(t,s);

inc(k)

end;



getmem(a,k*256);

close(t);

reset(t);

for i:=1 to k do

readln(t,a^[i]);

close(t);

for i:=1 to k-1 do

begin

for j:=i+1 to k do

if stricomp(a^[i],a^[j])>0 then

begin

strcopy(s,a^[j]);

strcopy(a^[j],a^[i]);

strcopy(a^[i],s);