Advertisement
spasnikolov131

Untitled

Mar 6th, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _01._Sum_Adjacent_Equal_Numbers
  6. {
  7. internal class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<double> numbers = Console.ReadLine()
  12. .Split(" ", StringSplitOptions.RemoveEmptyEntries)
  13. .Select(double.Parse)
  14. .ToList();
  15.  
  16. for (int i = 0; i < numbers.Count - 1; i++)
  17. {
  18. double currentIndex = numbers[i];
  19. double nextIndex = numbers[i + 1];
  20.  
  21. if (currentIndex + nextIndex == numbers[i])
  22. {
  23. double result = numbers[i] + currentIndex + nextIndex;
  24. Console.WriteLine(result);
  25. }
  26. }
  27. }
  28. }
  29. }
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement