Pascal-超急!!!!这段pascal代码为什么读不进程序,编译通过,但是run就出现exitcode=207 代码贴不完
var
w0,h0:integer;
w,h:array [1..300] of integer; {width and height of each rectangles}
used:array [1..300] of boolean; n:integer; {amount of rectangles}
state:array [1..300,1..4] of integer; {put rectangles}
v:integer;{v rectangles put}
legalpos:array [1..500000,1..7] of integer; {available legal position of newly put
rectangle}
legaln:integer; {amount of avalible legal position}
dmin:array [1..500000] of integer;
c:array [1..500000] of real;
c1:array [1..50000] of integer;
n1:integer;
procedure init;
var
i:integer;
begin
assign(input,'in.txt');
reset(input);
readln(w0,h0);
readln(n);
for i:=1 to n do
readln(w[i],h[i]);
close(input);
end;
procedure outit;
var
i:integer;
savailable:integer;
sused:integer;
notusedrate:real;
nused:integer;
flag:boolean;
begin
flag:=true;
savailable:=w0*h0; sused:=0;
nused:=0;
for i:=1 to n do
if used[i] then
begin
sused:=sused+w[i]*h[i];
inc(nused);
end;
notusedrate:=(savailable-sused)*100/savailable;
assign(output,'out.txt');
rewrite(output);
writeln('Here are the results:');
writeln('===========================');
writeln('Given rectangles:',n);
writeln('Used rectangles:',nused);
writeln('Whole area:',savailable);
writeln('Filled area:',sused);
writeln('Not used area rate:',notusedrate:0:3,'%');
writeln('===========================');
writeln('Location of each rectangle:');
for i:=5 to v do
writeln('(',state[i,1],',',state[i,2],') (',state[i,3],',',state[i,4],')');
writeln('===========================');
writeln('Not used rectangles:');
for i:=1 to n do
if not used[i] then
begin
writeln(w[i],',',h[i]);
flag:=false;
end;
if flag then
writeln('None');
close(output);
halt;
end;
procedure initiate; begin
state[1,1]:=-1;
state[1,2]:=0;
state[1,3]:=0;
state[1,4]:=h0+1;
state[2,1]:=0;
state[2,2]:=h0;
state[2,3]:=w0+1;
state[2,4]:=h0+1;
state[3,1]:=w0;
state[3,2]:=-1;
state[3,3]:=w0+1;
state[3,4]:=h0;
state[4,1]:=-1;
state[4,2]:=-1;
state[4,3]:=w0;
state[4,4]:=0; {define border}
fillchar(used,sizeof(used),false);
v:=4;
end;
function dis(x1,y1,a1,b1,i:integer):integer;
var
x2,y2,a2,b2:integer;
begin
x2:=state[i,1];
y2:=state[i,2];
a2:=state[i,3];
b2:=state[i,4];
if (a2<x1) and (y2>b1) then
begin
dis:=x1-a2+y2-b1;
exit;
end;
if (a1<x2) and (y2>b1) then
begin
dis:=x2-a1+y2-b1; exit;
end;
if (a1<x2) and (y1>b2) then
begin
dis:=x2-a1+y1-b2;
exit;
end;
if (a2<x1) and (y1>b2) then
begin
dis:=x1-a2+y1-b2;
exit;
end;
if y2>=b1 then
begin
dis:=y2-b1;
exit;
end;
if y1>=b2 then
begin
dis:=y1-b2;
exit;
end;
if x1>=a2 then
begin
dis:=x1-a2;
exit;
end;
if x2>=a1 then
begin
dis:=x2-a1;
exit;
end;
dis:=-1;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“used:array [1..300] of boolean; ”
数组用作布尔值?