Advertisement
bullit3189

Condense Array To Number

Jan 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Program
  5. {
  6. public static void Main()
  7. {
  8. int [] nums = Console.ReadLine().Split().Select(int.Parse).ToArray();
  9.  
  10.  
  11.  
  12. int counter = nums.Length;
  13.  
  14. while (counter >1)
  15. {
  16.  
  17.  
  18. for (int i=0; i<nums.Length-1; i++)
  19. {
  20. nums [i]= nums[i]+nums [i+1];
  21. }
  22. counter--;
  23. }
  24.  
  25. Console.WriteLine(nums[0]);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement