Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Test
  6. {
  7.     public class Program
  8.     {
  9.         public static void Main()
  10.         {
  11.             int[] nums = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.            
  13.            
  14.               while(nums.Length > 1)
  15.               {
  16.                 int[] condensed = new int[nums.Length - 1];
  17.  
  18.                 for(int i = 0; i < nums.Length - 1; i ++)
  19.                 {
  20.                     condensed[i] = nums[i] + nums[i + 1];
  21.                 }
  22.            
  23.                 nums = condensed;
  24.  
  25.                
  26.               }
  27.  
  28.             Console.WriteLine(string.Join(" ", nums));
  29.  
  30.  
  31.         }
  32.  
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement