void bubbleSort(int A[],int n) { int i,j; int temp; for(i=0;i<n;i++) { for(j=0;j<n-i;j++) { if(A[j]>A[j+1]) { temp=A[j]; A[j]=A[j+1]; A[j+1]=temp; } } } } Example 11Source File: Bubble_Sort.cpp From Algo_Ds_Notes with GNU General Public License...
For Each c In a Print c; Next End Sub 冒泡排序Pascal代码 program bubblesort; const N=20; MAX=10; var a:array[1..N] of 1..MAX; temp,i,j:integer; begin randomize; for i:=1 to N do a:=1+random(MAX); writeln('Array before sorted:'); for i:=1 to N do write(a,' ');...
Before we implement the Bubble Sort algorithm in a programming language, let's manually run through a short array only one time, just to get the idea. Step 1:We start with an unsorted array. [7,12,9,11,3] Step 2:We look at the two first values. Does the lowest value come first?
sort-algo / 01_bubble_sort.py 01_bubble_sort.py662 Bytes 一键复制编辑原始数据按行查看历史 tianyuchan提交于3个月前.01 冒泡排序, 02 选择排序, 03 插入排序 12345678910111213141516171819 defbubble_sort(nums:list[int]): """冒泡排序"""# 升序:把最大值“冒泡”到右边 ...