procedure TForm7.Button1Click(Sender: TObject);
var
a,b,c,d,e,t1,t2,temp:real;
function largest(d1,d2,d3:real):real;
var
cul:real;
begin
if d1>d2 then cul:=d1 else cul:=d2;
if d3>cul then cul:=d3;
largest:=cul
end;
begin
t1:=largest(a,b,c);
t2:=largest(d,e,t1)
end;
begin
if a<t2 then
begin
temp:=t2; t2:=a;a:=temp;
end;
end;
edit1.text:=floattostr(a);
edit2.text:=floattostr(b);
edit3.text:=floattostr(c);
edit4.text:=floattostr(d);
end.

解决方案 »

  1.   

    Var a,b,c,d,temp:real;
    begin
        a:=10.5;b:=9.5;c:=11.5;d:=12;
        temp:=max(max(max(a,b),c),d);
        if b=temp then b:=a
        else if c=temp then c:=a
        else if d=temp then d:=a;
        a:=temp;
        temp:=max(max(b,c),d);
        if c=temp then c:=b
        else if d=temp then d:=b;
        b:=temp;
        temp:=max(c,d);
        if temp=d then d:=c;
        c:=temp;
        edit1.text:=floattostr(a);//最大
        edit2.text:=floattostr(b);
        edit3.text:=floattostr(c);
        edit4.text:=floattostr(d);//最小
    end;
      

  2.   

    上面要加
    uses math;
      

  3.   

    var
      a,b,c,d,tmp,max:Integer;  
      Numbers:array [0..3] of PInteger  //指针数组
    begin
      //assign a,b,c,d
      .....
      
      Numbers[0]=@a;
      Numbers[1]=@b;
      Numbers[2]=@c;
      Numbers[3]=@d;  max:=0;  
      for i:=0 to 3 do
      begin
        if Numbers[i]^>Numbers[max]^ then max:=i;
      end    tmp:=a;
      a:=Numbers[max]^;
      Numbers[max]^=tmp;
    end;end;