标签:temp col void 简单 单选 排序 stat ++ 简单选择
package com.example.demo.dataStructure.sort; // 简单选择排序 public class SelectSort { public static void selectSort(int[] arg) { for (int i= 0;i< arg.length - 1;i++) { int k = i; for (int j=k+1;j<arg.length;j++) { if (arg[j] < arg[k]) { k = j; } } if (i != k) { int temp = arg[i]; arg[i] = arg[k]; arg[k] = temp; } } } public static void main(String[] args) { int[] arg = {9,8,7,6,5,4,3,1,2}; selectSort(arg); for (int i = 0;i< arg.length;i++) { System.out.print(arg[i]); } } }
标签:temp col void 简单 单选 排序 stat ++ 简单选择
原文地址:https://www.cnblogs.com/xiaobaobei/p/9638166.html