Advertisement
Teo_Yanchev

CondenseArrayToNumber

Sep 7th, 2020
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _8.CondenseArrayToNumber
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int[] nums = Console.ReadLine()
  11. .Split()
  12. .Select(int.Parse)
  13. .ToArray();
  14.  
  15. int length = nums.Length - 1;
  16. int[] condensed = new int[length];
  17.  
  18. while (length > 0)
  19. {
  20. for (int i = 0; i < length; i++)
  21. {
  22. condensed[i] = nums[i] + nums[i + 1];
  23. }
  24.  
  25. for (int i = 0; i < length; i++)
  26. {
  27. nums[i] = condensed[i];
  28. }
  29.  
  30. length -= 1;
  31. }
  32. Console.WriteLine($"{nums[0]}");
  33.  
  34. }
  35. }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement