SZNOI d018题解

来源:互联网 发布:心蓝数据官网 编辑:程序博客网 时间:2024/05/29 18:26
const n=3;var a:array[1..5] of longint;    i,j,k,temp:longint;Procedure sort;beginfor i:=1 to n do for j:=1 to n-i do begin  if a[j]<a[j+1] then begin   temp:=a[j];   a[j]:=a[j+1];   a[j+1]:=temp;  end;  end;end;beginfor i:=1 to n do read(a[i]);sort;for i:=1 to n do write(a[i],' ');end.

三数排序


我竟然用了冒泡。。。就三个数啊!!!你怎么不用快排。。。

打擂台方式即可实现,每次判断两次而已。。。