Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package p03_Arrays.Lab;
- import java.util.Arrays;
- import java.util.Scanner;
- public class P07_CondenseArrayToNumber {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int[] nums = Arrays.stream(console.nextLine().split(" "))
- .mapToInt(Integer::parseInt).toArray();
- int[] condensed = new int[nums.length - 1];
- for (int i = 0; i < condensed.length; i++) {
- nums = condensed(nums);
- }
- System.out.println(nums[0]);
- }
- private static int[] condensed(int[] nums) {
- int[] condensed = new int[nums.length - 1];
- for (int i = 0; i < condensed.length; i++) {
- condensed[i] = nums[i] + nums[i + 1];
- }
- return condensed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement