import java.util.Scanner;
public class Test {
public static int cd(){
int i ;
System.out.println("*********************");
System.out.println("*******éæ©æåº******");
System.out.println("***** 1 ååº*******");
System.out.println("***** 2 éåº*******");
System.out.println("***** 0 éåº*******");
System.out.println("*********************");
Scanner sc = new Scanner(System.in);
System.out.print("请è¾å
¥ä½ çéæ©ï¼");
i = sc.nextInt();
return i;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("è¾å
¥n:");
int n = sc.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; i++){
System.out.print("è¾å
¥ç¬¬[ " + (i + 1) +" ]ä¸ªæ° : ");
a[i] = sc.nextInt();
}
int i ;
i = cd();
while(i != 0){
switch (i) {
case 1:
for (i = 0; i < a.length - 1; i++) {
int min = i;
for (int j = i + 1; j < a.length; j++) {
if (a[min] > a[j]) {
min = j;
}
}
if (min != i) {
int temp = a[i];
a[i] = a[min];
a[min] = temp;
}
}
System.out.println("ååºæåºåçç»æ : ");
for(int temp : a){
System.out.print(temp + " ");
}
System.out.println();
break;
case 2:
for (i = 0; i < a.length - 1; i++) {
int min = i;
for (int j = i + 1; j < a.length; j++) {
if (a[min] < a[j]) {
min = j;
}
}
if (min != i) {
int temp = a[i];
a[i] = a[min];
a[min] = temp;
}
}
System.out.println("éåºæåºåçç»æ : ");
for(int temp : a){
System.out.print(temp + " ");
}
System.out.println();
break;
case 0:
System.out.println("exit!");
break;
}
i = cd();
}
}
}
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/7af40ad162d9f2d3009adb58acec8a136227ccfa?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)