pascal 语言:输入你要输入的数量,然后输入时间,输出按...
发布网友
发布时间:2024-10-19 19:24
我来回答
共2个回答
热心网友
时间:2024-10-24 07:47
type
atype=array[1..10000] of string;
var
n,i:longint;
a:atype;
procedure qsort(l,r:longint);
var
x,t:string;
i,j:longint;
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
t:=a[i]; a[i]:=a[j]; a[j]:=t;
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(input,'a.in'); reset(input);
assign(output,'a.out'); rewrite(output);
readln(n);
for i:=1 to n do
readln(a[i]);
qsort(1,n);
for i:=1 to n do
writeln(a[i]);
close(input); close(output);
end.
热心网友
时间:2024-10-24 07:49
快速排序
需要详细代码么?