Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int[] arr = Arrays
- .stream(scanner.nextLine().split(" "))
- .mapToInt(Integer::parseInt)
- .toArray();
- int[] sumArr = new int[arr.length];
- int r = Integer.parseInt(scanner.nextLine()),
- lastElement;
- for (int i = 0; i < r; i++) {
- lastElement = arr[arr.length - 1];
- for (int k = arr.length - 1; k > 0; k--) {
- arr[k] = arr[k - 1];
- sumArr[k] += arr[k];
- }
- arr[0] = lastElement;
- sumArr[0] += arr[0];
- }
- for (int element : sumArr) {
- System.out.printf("%d ", element);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement