/*
排序练习
1,排序函数-确认返回值-无
-未知参数-有
-if语句-前一个数与后一个数比较后判断是否互换-最值储存在arr[0]
-for语句-循环嵌套
2,输出函数-确认返回值-无
-未知参数-有
-遍历函数-for语句
-优化输出格式
*/
class ArrayTest{
public static void selectSort(int[] arr){
for(int x=0;x<arr.length;x++){
for(int y=x+1;y<arr.length;y++){
int temp=0;
if(arr[x]<arr[y]){
temp=arr[x];
arr[x]=arr[y];
arr[y]=temp;
}
}
}
}
public static void printArray(int[] arr){
for(int x=0;x<arr.length;x++){
if(x!=arr.length-1){
System.out.print(arr[x]+",");
}
else{
System.out.println(arr[x]);
}
}
}
public static void main(String[] args){
int[] arr=new int[]{3,2,6,7,5,4,9,0,1};
printArray(arr);
selectSort(arr);
printArray(arr);
}
}