这个pascal 程序为啥子会出现segmentation fault 呢。。求真相。。。
vara,b,x,y,p,q,g,h:array[0..3000]oflongint;e,i,j,t,s,c,m,n,k,l,d:longint;procedureppt...
var
a,b,x,y,p,q,g,h:array[0..3000]of longint;
e,i,j,t,s,c,m,n,k,l,d:longint;
procedure ppt;
begin
t:=1;
for i:=1 to m do
begin
if a[i]=0 then inc(t) else
begin
g[t]:=i;
inc(t);
dec(a[i]);
end;
end;
if t<=m then exit
else ppt;
end;
procedure pps;
begin
s:=1;
for i:=1 to n do
begin
if b[i]=0 then inc(t) else
begin
h[s]:=i;
inc(s);
dec(b[i]);
end;
end;
if s<=n then exit
else pps;
end;
begin
assign(input,'1007.in');
reset(input);
assign(output,'1007.out');
rewrite(output);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
readln(m,n,k,l,d);
for i:=1 to d do
begin
readln(x[i],y[i],p[i],q[i]);
if y[i]=q[i] then
begin
e:=x[i];
if x[i]>p[i] then e:=p[i];
inc(a[e]);
end;
if x[i]=p[i] then
begin
e:=y[i];
if y[i]>q[i] then e:=q[i];
inc(b[e]);
end;
end;
ppt;
for c:=1 to t do
write(g[c],' ');
writeln;
pps;
for c:=1 to s do
write(h[c],' ');
close(input);
close(output);
end.
啊。。郁闷了纠结了帮忙看看吧。。
3Q、·~~
额。。我后来改对了,但是不知道这个是为什么错。
其实不是问应该怎样,是不明白自己的哪里错了。。
望高人指点。。 展开
a,b,x,y,p,q,g,h:array[0..3000]of longint;
e,i,j,t,s,c,m,n,k,l,d:longint;
procedure ppt;
begin
t:=1;
for i:=1 to m do
begin
if a[i]=0 then inc(t) else
begin
g[t]:=i;
inc(t);
dec(a[i]);
end;
end;
if t<=m then exit
else ppt;
end;
procedure pps;
begin
s:=1;
for i:=1 to n do
begin
if b[i]=0 then inc(t) else
begin
h[s]:=i;
inc(s);
dec(b[i]);
end;
end;
if s<=n then exit
else pps;
end;
begin
assign(input,'1007.in');
reset(input);
assign(output,'1007.out');
rewrite(output);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
readln(m,n,k,l,d);
for i:=1 to d do
begin
readln(x[i],y[i],p[i],q[i]);
if y[i]=q[i] then
begin
e:=x[i];
if x[i]>p[i] then e:=p[i];
inc(a[e]);
end;
if x[i]=p[i] then
begin
e:=y[i];
if y[i]>q[i] then e:=q[i];
inc(b[e]);
end;
end;
ppt;
for c:=1 to t do
write(g[c],' ');
writeln;
pps;
for c:=1 to s do
write(h[c],' ');
close(input);
close(output);
end.
啊。。郁闷了纠结了帮忙看看吧。。
3Q、·~~
额。。我后来改对了,但是不知道这个是为什么错。
其实不是问应该怎样,是不明白自己的哪里错了。。
望高人指点。。 展开
展开全部
排座椅吧
写的太复杂了,堆栈溢出了
var n,m,n1,m1,x1,y1,k,x2,y2,i,j:longint;
a,b,c,d:array[1..1500]of longint;
procedure swap(var x,y:longint);
var t:longint;
begin
t:=x;
x:=y;
y:=t;
end;
begin
readln(n,m,n1,m1,k);
for i:=1 to k do begin
readln(x1,y1,x2,y2);
if x1<>x2 then
if x1>x2 then inc(a[x2])
else inc(a[x1]);
if y1<>y2 then
if y1>y2 then inc(b[y2])
else inc(b[y1]);
end;
for i:=1 to n do c[i]:=i;
for i:=1 to m do d[i]:=i;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then begin
swap(a[i],a[j]);
swap(c[i],c[j]);
end;
for i:=1 to m-1 do
for j:=i+1 to m do
if b[i]<b[j] then begin
swap(b[i],b[j]);
swap(d[i],d[j]);
end;
for i:=1 to n1-1 do
for j:=i+1 to n1 do
if c[i]>c[j] then swap(c[i],c[j]);
for i:=1 to m1-1 do
for j:=i+1 to m1 do
if d[i]>d[j] then swap(d[i],d[j]);
for i:=1 to n1-1 do write(c[i],' ');
writeln(c[n1]);
for i:=1 to m1-1 do write(d[i],' ');
writeln(d[m1]);
end.
不用堆栈,排序就可以了
写的太复杂了,堆栈溢出了
var n,m,n1,m1,x1,y1,k,x2,y2,i,j:longint;
a,b,c,d:array[1..1500]of longint;
procedure swap(var x,y:longint);
var t:longint;
begin
t:=x;
x:=y;
y:=t;
end;
begin
readln(n,m,n1,m1,k);
for i:=1 to k do begin
readln(x1,y1,x2,y2);
if x1<>x2 then
if x1>x2 then inc(a[x2])
else inc(a[x1]);
if y1<>y2 then
if y1>y2 then inc(b[y2])
else inc(b[y1]);
end;
for i:=1 to n do c[i]:=i;
for i:=1 to m do d[i]:=i;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then begin
swap(a[i],a[j]);
swap(c[i],c[j]);
end;
for i:=1 to m-1 do
for j:=i+1 to m do
if b[i]<b[j] then begin
swap(b[i],b[j]);
swap(d[i],d[j]);
end;
for i:=1 to n1-1 do
for j:=i+1 to n1 do
if c[i]>c[j] then swap(c[i],c[j]);
for i:=1 to m1-1 do
for j:=i+1 to m1 do
if d[i]>d[j] then swap(d[i],d[j]);
for i:=1 to n1-1 do write(c[i],' ');
writeln(c[n1]);
for i:=1 to m1-1 do write(d[i],' ');
writeln(d[m1]);
end.
不用堆栈,排序就可以了
追问
额。。我后来改对了,但是不知道这个是为什么错。
其实不是问应该怎样,是不明白自己的哪里错了。。
望高人指点。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
好长......没耐心读下去
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询