主题:快排啊……
var f1,f2:text;
var a:array[0..10000] of integer;
var n,i:integer;
procedure swap(var n:integer; var m:integer);
var tmp:integer;
begin
tmp:=n;
n:=m;
m:=tmp;
end;
procedure qsort(l,r:longint);
var i,j,x:integer;
begin
i:=l;
j:=r;
x:=a[(l+r)div 2];
repeat
while a[i]<x do inc(i);
while a[j]>x do dec(j);
if i<=j then
begin
swap(a[i],a[j]);
inc(i);
dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
assign(f1,'jinru.in');
reset(f1);
read(f1,n);
for i:=1 to n do
read(f1 ,a[i]);
qsort(a[1],a[n]);
close(f1);
assign(f2,'chulai.out');
rewrite(f2);
for i:=1 to n do
write(f2,a[i],' ');
close(f2);
end.
求大家帮我看一下到底有什么错误啊
就是不出结果
就是不出结果……[em52][em52][em52][em52][em52]
var a:array[0..10000] of integer;
var n,i:integer;
procedure swap(var n:integer; var m:integer);
var tmp:integer;
begin
tmp:=n;
n:=m;
m:=tmp;
end;
procedure qsort(l,r:longint);
var i,j,x:integer;
begin
i:=l;
j:=r;
x:=a[(l+r)div 2];
repeat
while a[i]<x do inc(i);
while a[j]>x do dec(j);
if i<=j then
begin
swap(a[i],a[j]);
inc(i);
dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
assign(f1,'jinru.in');
reset(f1);
read(f1,n);
for i:=1 to n do
read(f1 ,a[i]);
qsort(a[1],a[n]);
close(f1);
assign(f2,'chulai.out');
rewrite(f2);
for i:=1 to n do
write(f2,a[i],' ');
close(f2);
end.
求大家帮我看一下到底有什么错误啊
就是不出结果
就是不出结果……[em52][em52][em52][em52][em52]