1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
public static void simpleSelectionSort( int [] a, int n) {
int key, temp;
for ( int i= 0 ; i<n; i++) {
key = selectMiniKey(a, n, i);
if (key != i) {
temp = a[i];
a[i] = a[k];
a[k] = temp;
}
}
} public static void selectMiniKey( int [] a, int n, int i) {
int k = i;
for ( int j=i+ 1 ; j<n; j++) {
if (a[k] > a[i]) {
k = j;
}
}
return k;
}
|
本文转自yeleven 51CTO博客,原文链接:http://blog.51cto.com/11317783/1978034