import java.util.Scanner;
class ShuZu {
public static void main(String[] args) {
int[] arr=new int[6];
Scanner sc=new Scanner(System.in);
System.out.println("请输入第一个整数:");
arr[0]=sc.nextInt();
System.out.println("请输入第二个整数:");
arr[1]=sc.nextInt();
System.out.println("请输入第三个整数:");
arr[2]=sc.nextInt();
System.out.println("请输入第四个整数:");
arr[3]=sc.nextInt();
System.out.println("请输入第五个整数:");
arr[4]=sc.nextInt();
System.out.println("请输入第六个整数:");
arr[5]=sc.nextInt();
fanZhuan(arr);
jiJiaoHuan(arr);
jiaoHuan4(arr);
print(arr);
}
public static void fanZhuan(int[] arr) {
for (int x=0;x<arr.length/2 ;x++ ) {
jiaoHuan(arr,x,arr.length-1-x);
}
}
public static void jiaoHuan(int[] arr,int a,int b) {
int x=arr[a];
arr[a]=arr[b];
arr[b]=x;
}
public static void jiJiaoHuan(int[] arr) {
for (int x=1;x<arr.length ;x+=2 ) {
if (x+2<=arr.length-1) {
jiaoHuan(arr,x,x+2);
}
}
}
public static void jiaoHuan4(int[] arr) {
int m=0;
if (arr.length-1%2==0) {
m=arr.length-1-1;
} else {
m=arr.length-1;
}
jiaoHuan(arr,m,1);
}
public static void print(int[] arr) {
for (int x=0;x<arr.length ;x++ ) {
System.out.print(arr[x]+" ");
}
}
} |
|