这个pascal程序错在哪儿?

Larkinboy 2001-10-08 10:39:55
program wxyunsuan;
var
a:array [1..5] of integer;{save five +integer}
m,i1,i2,i3,i4,step:integer; {ix is used for repeat}
s1,s2,s3,s4:real;
procedure print (fu:integer);
begin
case fu of
1:write('+');
2:write('-');
3:write('/');
4:write('*');
end;
end;
function run (num1,num2:real;fu:integer):real;
begin
case fu of
1:run:=num1+num2;
2:run:=num1-num2;
3:begin
if (num2<>0)
then run:=num1/num2
else run:=maxint;
end;
4:run:=num1*num2;
end;
end;
procedure output(i1,i2,i3,i4:integer);
begin
inc (step);
writeln ('step=',step);
write (a[1]);print(i1);
write (a[2]);print(i2);
write (a[3]);print(i3);
write (a[4]);print(i4);
write (a[5]);
write ('=');
write (m);
readln;
end;
procedure input;{read data}
var
i:integer;
begin
for i:=1 to 5 do
begin
write ('a',i,'=');
readln (a[i]);
end;
write ('m=');
readln (m);
end;
begin
input;
for i1:=1 to 4 do
begin
if (i1=4) and (a[2]=0)
then continue
else s1:=run (a[1],a[2],i1);
for i2:=1 to 4 do
begin
if (i2=4) and (a[3]=0)
then continue
else s2:=run (s1,a[3],i2);
for i3:=1 to 4 do
begin
if (i3=4) and (a[4]=0)
then continue
else s3:=run (s2,a[4],i3);
for i4:=4 to 4 do
begin
if (i4=4) and (a[5]=0)
then continue
else begin
s4:=run (s3,a[5],i4);
if (i4=m)
then output (i1,i2,i3,i4);
end;
end;
end;
end;
end;
if step=0 then writeln ('no answer!');
end.
...全文
36 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

33,028

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧