有n个整数,使其前面各数顺序向后移m个位置,最后m个数变成最前面的m个数`
int N = 5;
int[] a = new int[N];
Scanner s = new Scanner(System.in);
System.out.println(“请输入10个整数:”);
for (int i = 0; i < N; i++) {
a[i] = s.nextInt();
}
System.out.print(“你输入的数组为:”);
for (int i = 0; i < N; i++) {
System.out.print(a[i] + " “);
}
System.out.print(”\n请输入向后移动的位数:");
int m = s.nextInt();
for (int i = 1; i <= m; i++) {
int v= a[a.length-1];
for (int j = a.length-1; j >=1; j–) {
a[j] = a[j-1];
}
a[0] = v;
}
System.out.println(Arrays.toString(a));