C code:
1 //对数组a[MAX]进行冒泡排序 2 void BubbleSort(int a[]) 3 { 4 int temp = 0; //临时变量 5 int i = 0; 6 for (i=0; i<MAX; i++) 7 { 8 if ( a[i] > a[i+1]) 9 { 10 temp = a[i]; 11 a[i] = a[i+1]; 12 a[i+1] = temp; 13 } 14 } 15 }
时间: 2024-10-06 20:40:29
C code:
1 //对数组a[MAX]进行冒泡排序 2 void BubbleSort(int a[]) 3 { 4 int temp = 0; //临时变量 5 int i = 0; 6 for (i=0; i<MAX; i++) 7 { 8 if ( a[i] > a[i+1]) 9 { 10 temp = a[i]; 11 a[i] = a[i+1]; 12 a[i+1] = temp; 13 } 14 } 15 }