free pascal编程输入3个整数,从小到大排序后输出
这道题用选仔谨择族举排序来做,核心部分:
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
t:=a[j];
a[j]:=a[i];
a[i]:=t;
end;
参考程序(pascal):兆戚碧
const n=3;
var
a:array[1..3] of longint;
i,j,t:longint;
begin
for i:=1 to n do read(a[i]); readln;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
t:=a[j];
a[j]:=a[i];
a[i]:=t;
end;
for i:=1 to n do write(a[i],' '); writeln;
end.
var a,b,c,t:longint;
begin
read(a,b,c);
if b>a then begin t:=a;a:=b;b:=t;end;
if c>冲轮b then begin t:=b;b:=c;c:=t;end;
if c>a then begin t:=a;a:=c;c:=t;end;
writeln(c,'宽判戚 '慎陵,b,' ',a);
end.
sddddddd
用if语句