public class Test{

public static void main(String args[]){
int[] a = {34, 53, 13, 90, 78,99};
print(a);
selectSort(a);
print(a);
}

public static void print(int[] a){
for(int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println();
}

public static void selectSort(int[] a){
int k, temp;
for(int i = 0; i < a.length; i++){
k = i;
for(int j = i + 1; j < a.length; j++){
if(a[j] < a[i]){
k = j;
}
}
if(k != i){
temp = a[k];
a[k] = a[i];
a[i] = temp;
}
}
}
}

相关文章:

  • 2021-04-30
  • 2021-08-02
  • 2021-07-05
  • 2021-11-28
  • 2022-12-23
猜你喜欢
  • 2021-07-22
  • 2022-02-26
  • 2021-04-28
  • 2021-12-22
  • 2021-06-27
  • 2021-08-25
  • 2021-07-27
相关资源
相似解决方案