最大整数(连接多位数)

来源:互联网 发布:python replace into 编辑:程序博客网 时间:2024/05/29 04:23
var
 a:array[1..1000000] of string;
 n,i,x,j:longint;
 tmp:string;
function swap(i,j:longint):longint;
var
  tmp:string;
begin
  tmp:=a[i];
  a[i]:=a[j];
  a[j]:=tmp;
end;
begin
 readln(n);
 for i:=1 to n do
 begin
  read(x);
  str(x,a[i]);
 end;
 for i:=1 to n-1 do
  for j:=i+1 to n do
  if (a[i]<a[j]) then swap(i,j);
  for i:=1 to n-1 do
   for j:=1 to n-1 do
   if (pos(a[j+1],a[j])<>0)and(a[j,length(a[j+1])+1]<a[j,1]) then swap(j,j+1);
   for i:=1 to n do write(a[i]);
   writeln;
end.
1 0