gb-java-devel/src/s02-h2-shifter.java

12 lines
274 B
Java
Raw Normal View History

2022-12-15 10:24:31 +03:00
private static void shifter(int[] a, int n) {
n %= a.length;
int shift = a.length + n;
shift %= a.length;
for (int i = 0; i < shift; i++) {
int temp = a[a.length - 1];
System.arraycopy(a, 0, a, 1, a.length - 1);
a[0] = temp;
}
}