Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _7.CondenseArrayToNumber
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- if (arr.Length == 1)
- {
- Console.WriteLine(arr[0]);
- return;
- }
- else
- {
- while (arr.Length != 1)
- {
- int[] condensed = new int[arr.Length - 1];
- for (int i = 0; i < arr.Length-1; i++)
- {
- condensed[i] = arr[i] + arr[i + 1];
- }
- arr = condensed;
- }
- Console.WriteLine(arr[0]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement