delphi 中任意输入三个数,求中间数?
1个回答
展开全部
procedure TForm2.Button2Click(Sender: TObject);
var
n1,n2,n3:Integer;
begin
n1:=StrToInt(Edit1.Text);
n2:=StrToInt(Edit2.Text);
n3:=StrToInt(Edit3.Text);
if n1>n2 then
if n2>n3 then
ShowMessage(IntToStr(n2))
else
if n1>n3 then
ShowMessage(IntToStr(n3))
else
ShowMessage(IntToStr(n1))
else
if n1>n3 then
ShowMessage(IntToStr(n1))
else
if n2>n3 then
ShowMessage(IntToStr(n3))
else
ShowMessage(IntToStr(n2))
end;
var
n1,n2,n3:Integer;
begin
n1:=StrToInt(Edit1.Text);
n2:=StrToInt(Edit2.Text);
n3:=StrToInt(Edit3.Text);
if n1>n2 then
if n2>n3 then
ShowMessage(IntToStr(n2))
else
if n1>n3 then
ShowMessage(IntToStr(n3))
else
ShowMessage(IntToStr(n1))
else
if n1>n3 then
ShowMessage(IntToStr(n1))
else
if n2>n3 then
ShowMessage(IntToStr(n3))
else
ShowMessage(IntToStr(n2))
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询