d634.
魔法卡magic
--
jack1
| From: [122.100.198.119] |
發表日期
:
2014-04-04 23:46
求助
感謝~~
var n,i:longint;
s:array[1..100000] of string;
procedure swap(var a,b:string);
var t:string;
begin
t:=a;
a:=b;
b:=t;
end;
procedure quicksort(i,j:longint);
var p,q:longint;
t:string;
begin
if i<j then
begin
p:=i+1;
q:=j;
t:=s[i];
while p<q do
begin
while (t>s[p]) and (p<j) do inc(p);
while (t<s[q]) and (q>i) do dec(q);
if p<q then swap(s[p],s[q]);
end;
if p<>i then swap(s[i],s[p-1]);
quicksort(i,p-2);
quicksort(p,j);
end;
end;
begin
readln(n);
for i:=1 to n do
readln(s[i]);
quicksort(1,n);
for i:=1 to n do
writeln(s[i]);
end.