Advertisement
braveheart1989

Condense_Array_To_Number

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