摘要:
/* Logic : Suppose if the array is sorted till index i then we can sort the arry till i+1 by inserting i+1 th element in the correct position from 0 to i+1. The position at which (i+1)th ele... 阅读全文
摘要:
该算法的思想是每趟排序都使得较小的元素排到数列的前端,因此,被称为冒泡排序。 算法: 从数列的第一个元素起,比较相邻的两个元素,直到他们按如下顺序排列: a)比较相邻的两个元素,检查他们顺序是否正确( 第二个数必须比第一个数大) b)如果他们的顺序不对,则交换他俩的顺序 void BubbleSort(int *array,int number_of_elements){ ... 阅读全文