procedure bubble_sort; var i,j,k:integer; begin for i:=1 to n-1 do for j:=n downto i+1 do if a[j]<a[j-1] then swap( a[j],a[j-1]); {每次比较相邻元素的关系} end;