最大正数pascal程序

来源:互联网 发布:二叉树反转 java 编辑:程序博客网 时间:2024/03/29 17:02
var
n,i,x,j:longint;
s:array[0..20]of string;
begin
    readln(n);
    for i:=1 to n do//因为数据之间有空格,所以先读入成数字,再变为字符串
    begin
        read(x);
        str(x,s[i]);
    end;
    for i:=1 to n-1 do//要用选排
    begin
        for j:=i+1 to n do
        begin
            if s[i]+s[j]<s[j]+s[i] then//选排会将所有情况一一模拟,继而找出最大数
            begin
                s[0]:=s[i];
                s[i]:=s[j];
                s[j]:=s[0];
            end;
        end;
    end;
    for i:=1 to n do//排完序后,输出就可以了
    write(s[i]);
end.

0 0