这个错哪了
pascal吧
全部回复
仅看楼主
level 5
var
n,m,i,j,l,k,s:longint;
x:array[0..1000002] of longint;
procedure qsort(l,r:longint);
var
i,j,mid,p:longint;
begin
i:=l;j:=r;
mid:=x[(l+r) div 2];
while i<=j do
begin
while (x[i]<mid) do inc(i);
while (x[j]>mid) do dec(j);
begin
p:=x[i];x[i]:=x[j];x[j]:=p;
inc(i);dec(j);
end;
end;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
readln(n);
for i:=1 to n do
readln(x[i]);
qsort(1,n);
for i:=1 to n do
writeln(x[i]);
end.
快排,但是运行出来不对。
2014年07月13日 01点07分 1
level 5
我就把书中的a换成x就错了,什么意思啊
2014年07月13日 01点07分 2
我用的就是fp
2014年07月14日 01点07分
level 12
哪儿错了,FP运行出来对的
你用的TP吧,如果是的话,数组越界
2014年07月13日 07点07分 3
level 12
不对,是错了
但我不知道错那儿了
2014年07月13日 08点07分 4
level 5
输入:
6
65
32
8
74
13
90
输出:
32
8
13
65
74
90
2014年07月14日 01点07分 5
level 5
好吧,我少了一句if i<=j then
2014年07月14日 02点07分 6
1