import org.junit.Test;
public class test {
public static void main(String[] args) {
int a[] = {10,8,7,6,5};
int i = 0;
int j = 0;
int temp = 0;
int flag = 0;
int n = a.length;
for(i=0;i<n;i++){
temp = a[i];
flag = i;
for(j=i+1;j<n;j++){
if(a[j] < temp){
temp = a[j];
flag = j;
}
}
if(flag != i){
a[flag] = a[i];
a[i] = temp;
}
System.out.println(a[i]);
}
}
}
选择性排序
最新推荐文章于 2024-01-04 16:03:14 发布