Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Condense_Array_to_Number
- {
- class Program
- {
- static void Main()
- {
- //read the array
- string text = Console.ReadLine();
- int[] arrayNums = text.Split().Select(int.Parse).ToArray();
- //get the array length
- int n = arrayNums.Length - 1;
- if (arrayNums.Length == 1)
- Console.WriteLine(arrayNums[0]);
- else
- {
- while (arrayNums.Sum() - arrayNums[0] != 0)
- {
- for (int i = 0; i < arrayNums.Length - 1; i++)
- {
- arrayNums[i] = arrayNums[i] + arrayNums[i + 1];
- }
- arrayNums[n] = 0;
- n--;
- }
- Console.WriteLine(arrayNums[0]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement