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