Advertisement
azaria77

08._Condense_Array_to_Number

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