UNIX Free Pascal




. - 8


or (((s1[1]>='A')and(s1[1]<='Z'))and((s1[3]>='A')and(s1[3]<='Z')))

or (((s1[1]>='a')and(s1[1]<='z'))and((s1[3]>='a')and(s1[3]<='z')))))

and (s1[1]<=s1[3])or(s1[1]='-')

then

begin

for i:=Ord(s1[1]) to Ord(s1[3]) do

s2:=s2+Chr(i);

if s1[1]='-'then delete(s[1],1,1);

ex:=true;

end

else ex:=false;

end;

function expand(s1:string; var s2:string):boolean;

var

i:Byte;

tmpstr:String;

begin

s2:=s1;

while (pos('-',s2)>0) do

if (pos('-',s2)>1)and(pos('-',s2)<Ord(s2[0])) then

begin

if ex(copy(s2,pos('-',s2)-1,3),tmpstr) then

s2:=Copy(s2,1,pos('-',s2)-2)+tmpstr+Copy(s2,pos('-',s2)+2,Ord(s2[0])-(pos('-',s2)+2))

else s2[pos('-',s2)]:='~';

end

else s2[pos('-',s2)]:='~';

While (pos('~',s2)>0) do s2[pos('~',s2)]:='-';

end;

var

m,n:string;

begin

repeat

Readln(m);

if ex(m,n) then expand(m,n);

if m='exit' then exit;

if expand(m,m) then writeln(m)

else writeln('Error');

Until False;

end.

13.16. , , ( ). .

Program demoupcase;

function ischar(c:char):boolean;

begin

if c in ['a'..'z'] then ischar:=true

else ischar:=false;

end;

function upcase(s:string):string;

var

i:Byte;

tmp:string;

begin

tmp:=s;

for i:=1 to ord(tmp[0]) do

if ischar(tmp[i]) then tmp[i]:=Chr(ord(tmp[i])-Ord('a')+Ord('A'));

upcase:=tmp;

end;

begin

writeln(upcase('abcderfFFF123***'));

readln;

end.

13.17. , .

program reverse;

var

F1,F2:Text;

tmpstr:string;

function revstr(s:string):string;

var

tmp:string;

begin

tmp:='';