- 笨笨的单词排序
- 2009-02-05 17:41:22 @
program p1500;
var
order:string;
s,i,t:integer;
temp:char;
a:array[1..1000]of string;
function less(s1,s2:string):boolean;
var
t1,i,j,q:integer;
ch:char;
begin
if s1=s2 then exit(false);
ch:=' ';
q:=length(s2);
t1:=abs(length(s1)-length(s2));
if length(s1)>length(s2)
then begin
for i:=1 to t1 do
s2:=s2+ch;
q:=length(s1);
end
else for i:=1 to t1 do
s1:=s1+ch;
for i:=1 to q do
begin
if s1[i]s2[i]
then for j:=1 to 27 do
begin
if order[j]=s1[i]
then exit(true);
if order[j]=s2[i]
then exit(false);
end;
end;
end;
{ function lesame(s1,s2:string):boolean;
var
t,i,j,q:integer;
ch:char;
begin
if s1=s2 then exit(true);
ch:=' ';
q:=length(s2);
t:=abs(length(s1)-length(s2));
if length(s1)>length(s2)
then begin
for i:=1 to t do
s2:=s2+ch;
q:=length(s1);
end
else for i:=1 to t do
s1:=s1+ch;
for i:=1 to q do
begin
if s1[i]s2[i]
then for j:=1 to 27 do
if order[j]=s1[i]
then exit(true)
else exit(false);
end;
end;
}
procedure sort_quick(l,r:integer);
var
i,j:integer;
x,y:string;
begin
i:=l;
j:=r;
x:=a[(l+r)div 2];
repeat
while less(a[i],x) do inc(i);
while less(x,a[j]) do dec(j);
if ij;
if i