public class fdsa {
public static void main(String[] args) {
int[] array = new int[] {3, 5, 6, 8, 2, 1, 9, 0, 7, 4};
int temp;
System.out.println("原数组为:");
printArray(array);
int index;
for (int i = 1; i < array.length; i ++)
{
index = 0;
for (int j = 1; j <= array.length - i ; j ++)
{
if (array[j] > array[index])
{
index = j;
}
temp = array[array.length - i];
array[array.length - i] = array[index];
array[index] = temp;
}
}
System.out.println("按照直接排序法升序排列后的数组为:");
printArray(array);
for (int i = 1 ; i < array.length;i++)
{
index = 0;
for(int j = 1; j <= array.length - i; j++)
{
if (array[j]
index = j;
}
temp = array[array.length - i];
array[array.length - i ] = array[index];
array[index] = temp;
}
}
System.out.println("按照直接排序法降序排列后的数组为:");
printArray(array);
}
public static void printArray(int[] array)
{
for (int i:array)
{
System.out.print(i + " ");
}
System.out.println("\n");
}
}
public class Test {
public static void main(String[] args) {
Test t=new Test();
int [] a1={1,25,9,8,3,4,7,6,5,45};
t.SelectSort(a1);
for(int i=0;i
}
}
public void SelectSort(int [] needSortArray){
int tmp=0;
for(int i=0;i
needSortArray[i]=needSortArray[j];
needSortArray[j]=tmp;
}
}
}
}
}