讨论 / 请问我的程序怎么了?老过不去5、6
wbx5223166 2008-10-01 07:24:00
点我顶贴 收藏 删除
请问我的程序怎么了?老过不去5、6:

program expandnew;

var

p1,p2,p3:integer;

ch:ansistring;

chresult:array[1..8000000]of char;

lin:char;

i,js,zs,j,xh,zjs:integer;

procedure printf;

var pr,pr2:integer;

begin

if (p3=1)and(p1=1) then

begin

for pr:=1 to zs do

for pr2:=1 to p2 do

write(chresult[pr]);

end;

if (p3=2)and(p1=1) then

begin

for pr:=zs downto 1 do

for pr2:=1 to p2 do

write(chresult[pr]);

end;

if (p3=1)and(p1=2) then

begin

for pr:=1 to zs do

for pr2:=1 to p2 do

write(upcase(chresult[pr]));

end;

if (p3=2)and(p1=2) then

begin

for pr:=zs downto 1 do

for pr2:=1 to p2 do

write(upcase(chresult[pr]));

end;

if p1=3 then

begin

for pr:=1 to zs do

for pr2:=1 to p2 do write(’*’);

end;

end;{printf end}

procedure pd(a,b:char);

begin

i:=1;

if( ((ord(a) >= 97)and(ord(a) <= 122))

and((ord(b) >= 48)and(ord(b) <= 57)) )

or

( ((ord(b) >= 97)and(ord(b) <= 122))

and((ord(a) >= 48)and(ord(a) <= 57)) )

then {left and right is different}

write(’-’)

else

if ord(a) >= ord(b) then write(’-’)

else

if (ord(a)+1) = ord(b) then

else

begin

while ord(a)+i < ord(b) do

begin

chresult[i]:=chr(ord(a)+i);

i:=i+1;

end;

zs:=i-1;

printf;

end;{if end}

end; {pd end}

begin

readln(p1,p2,p3);

read(ch);

zjs:=length(ch);js:=0;

ch[zjs+1]:=’ ’;

repeat

while ch[js+1]=’-’ do

begin

if (ch[js+2]<>’ ’)and(js<>0) then pd(ch[js],ch[js+2])

else write(’-’);

break;

end;

if (ch[js+1]<>’-’)and(ch[js+1]<>’ ’) then write(ch[js+1]);

inc(js);

until js>zjs;

readln;

end.

查看更多回复
提交回复