大学生如何办理visa卡:编程问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/08 12:44:27
编写一个用选择法对10整数排序的函数。在main方法中调用该函数,并且10个整数在main函数中使用赋初值的方法给出。

main
{int a[]={1,4,3,8,5,2,6,5,9,0,7};//赋初值
selectSort(a);//选择排序
System.out.println(a);//输出

}
public static void selectSort(int a[]) { //数组的选择排序
for (int n = a.length; n > 1; n--) {
int i = max(a, n);
int temp = a[i];
a[i] = a[n - 1];
a[n - 1] = temp;
}
}