将大数转化为小数,例如:
a:12351235 2151321 51514563 5132316
<=>b: 3 1 4 2
type
node=record
id,c:longint;
end;
var
a:array [1..10000] of node;
b:array [1..10000] of longint;
i,j,m,n:longint;
procedure cha(l,r:longint);
var
i,j,mid:longint;
t:node;
begin
i:=l;
j:=r;
mid:=a[(l+r) div 2].c;
while i<=j do
begin
while a[i].c<mid do inc(i);
while a[j].c>mid do dec(j);
if (i<=j) then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
inc(i);
dec(j);
end;
end;
if j>l then cha(l,j);
if i<r then cha(i,r);
end;
begin
readln(n);
for i:=1 to n do
begin
read(a[i].c);
a[i].id:=i;
end;
cha(1,n);
for i:=1 to n do
b[a[i].id]:=i;
for i:=1 to n do
writeln(b[i]);
end.
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/boyxiejunboy/article/details/46880289