Pascal-超急!!!!这段pascal代码为什么读不进程序,编译通过,但是run就出现exitcode=207 代码贴不完

发布于 2016-11-09 10:48:47 字数 3793 浏览 1331 评论 1

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晚风撩人 2017-07-16 15:31:31

“used:array [1..300] of boolean; ”
数组用作布尔值?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文