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> numbers = Console.ReadLine().Split(new char[] { ' ' }
- , StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
- for (int i = 1; i < numbers.Count - 1; i++)
- {
- int neighboringSum = numbers[i - 1] + numbers[i + 1];
- int primeNum = numbers[i];
- if (neighboringSum == primeNum)
- {
- numbers.RemoveAt(i + 1);
- numbers.RemoveAt(i - 1);
- i = 0;
- }
- else if (primeNum == numbers[i - 1])
- {
- numbers.RemoveAt(i - 1);
- i = 0;
- }
- else if (primeNum == numbers[i + 1])
- {
- numbers.RemoveAt(i + 1);
- i = 0;
- }
- }
- Console.WriteLine(string.Join(" ", numbers));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement