viraco4a

Untitled

Dec 12th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 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 task_5
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] nums = Console.ReadLine()
  14. .Split()
  15. .Select(s => int.Parse(s))
  16. .ToArray();
  17. int n = nums.Length;
  18. int i = 0;
  19. for (int j = (n - 1) * (n - 1); j > 0; i++, j--)
  20. {
  21. if (i == n - 1)
  22. {
  23. i = 0;
  24. }
  25. int[] condensed = new int[n];
  26. condensed[i] = nums[i] + nums[i + 1];
  27. nums[i] = condensed[i];
  28. }
  29. int result = nums[0];
  30. Console.WriteLine(result);
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment