编程实现将10个整数升序排列。
要求从键盘输入10个整数存放在一个一维数组中,调整10个数按从小到大的顺序排列,并输出。分别用冒泡法和选择法实现。(写两个程序)
求大神!!!!
selection-sort(A) for i = 2 to A.length: v = A[i] for j = i-1 down to 1: if A[j] > v: A[j+1] = A[j] A[j+1] = v
bubble-sort(A) j=A.length while j > 1: k = 1 for i = 1 to j - 1: if A[i] > A[i+1]: swap(A[i], A[i+1]) k = i j = k
[此贴子已经被作者于2016-12-1 18:43编辑过]