Advertisement
TeMePyT

Untitled

May 31st, 2018
114
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.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08.Condense_Array_to_Number
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14.  
  15. while(arr.Length>1)
  16. {
  17. int[] condensed = new int[arr.Length - 1];
  18. for (int i = 0; i < arr.Length; i++)
  19. {
  20. if (i == arr.Length-1)
  21. {
  22. break;
  23. }
  24. condensed[i] = arr[i] + arr[i + 1];
  25.  
  26. }
  27. arr = condensed;
  28. }
  29. Console.WriteLine(string.Join("", arr).ToArray());
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement