1008 数组元素循环右移问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int M = in.nextInt();
int[] arr = new int[100];
M = M % N;
for (int i = 0; i < N; i++) {
arr[i] = in.nextInt();
}
for (int i = N - M; i <= N - 1; i++) {
System.out.print(arr[i] + " ");
}
for (int i = 0; i < N - M - 1; i++) {
System.out.print(arr[i] + " ");
}
System.out.print(arr[N - M - 1]);
}
}

1008 数组元素循环右移问题
https://pisces34.github.io/2021/05/10/patB/basic-1008/
发布于
2021年5月10日
许可协议