import java.util.Scanner; public class Tenth { /*有n个整数,使其前面各数顺序向后移m个位置,最后m个数变成最前面的m个数*/ public static void main(String[] args){ Scanner input=new Scanner(System.in); System.out.println("您将输入的数字个数为:"); int a=input.nextInt(); int[] array=new int[a]; int t,i; System.out.println("您要交换的数字个数为:"); int b=input.nextInt(); System.out.println("请输入数组:"); for(i=0;i<a;i++) array[i]=input.nextInt(); System.out.println("交换之前数组为:"); for(i=0;i<a;i++) System.out.print(array[i]+" "); for(i=0;i<b;i++){ t=array[i]; array[i]=array[array.length-b+i]; array[array.length-b+i]=t; } System.out.println(" "+"交换之后数组为:"); for(i=0;i<a;i++) System.out.print(array[i]+" "); } }