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