Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _03.Spyfer
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> listOfNumbers = Console.ReadLine()
- .Split(new char[] {' '} , StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToList();
- int leftNeighboringElement = 0;
- int rightNeighboringElement = 0;
- if (listOfNumbers.Count == 0)
- {
- Console.WriteLine("Empty");
- return;
- }
- for (int index = 0; index < listOfNumbers.Count; index++)
- {
- leftNeighboringElement = index - 1 == -1 ? 0 : listOfNumbers[index - 1];
- rightNeighboringElement = index + 1 >= listOfNumbers.Count ? 0 : listOfNumbers[index + 1];
- if (leftNeighboringElement + rightNeighboringElement == listOfNumbers[index])
- {
- // Console.WriteLine("Condition1");
- if (!(index == 0))
- {
- listOfNumbers.RemoveAt(index - 1);
- }
- if (!(index >= listOfNumbers.Count))
- {
- listOfNumbers.RemoveAt(index);
- }
- index = 0;
- }
- //else
- //{
- // Console.WriteLine("Nothing Happens");
- //}
- }
- Console.WriteLine(string.Join(" ", listOfNumbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement