delphi编程 将任意输入的三个数字按顺序输出

来源:百度知道 编辑:UC知道 时间:2024/09/28 08:38:51
delphi编程 将任意输入的三个数字按顺序输出,比如输入 4 2 3 要输出:2 3 4 。

给源代码。

谢谢!!!!

program ConsoleApp;

{$APPTYPE CONSOLE}

uses
SysUtils;

procedure Swap(var n1,n2:Integer);
var
t:Integer;
begin
t:=n1;
n1:=n2;
n2:=t;
end;

var
a,b,c,t:Integer;
begin
{ TODO -oUser -cConsole Main : Insert code here }
write('input a,b,c:');
readln(a,b,c);

if a>b then
swap(a,b);
if a>c then
swap(a,c);
if b>c then
swap(b,c);

writeln('result:',a,' ',b,' ',c);
readln;
end.

排序嘛。很多经典的算法的。