svetliovd

Untitled

Jul 23rd, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 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 Spyfer
  8. {
  9.     class Spyfer
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.             Outer:
  15.             for (int i = 1; i < input.Count-1; i++)
  16.             {
  17.                 if (input[i] == input[i - 1] + input[i + 1])
  18.                 {
  19.                     input.RemoveAt(i - 1);
  20.                     input.RemoveAt(i);
  21.                     goto Outer;
  22.                 }
  23.             }
  24.             for (int i = 0; i < input.Count - 1; i++)
  25.             {
  26.                 if (input[i] == input[i + 1])
  27.                 {
  28.                     input.RemoveAt(i + 1);
  29.                     goto Outer;
  30.                 }
  31.             }
  32.             Console.WriteLine(string.Join(" ", input));
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment