Advertisement
YavorGrancharov

Remove_Elements_at_Odd_Positions

Jun 21st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 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 Remove_Elements_at_Odd_Positions
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<string> list = Console.ReadLine()
  14.                 .Split(new char[] { ' ' },
  15.                 StringSplitOptions.RemoveEmptyEntries)
  16.                 .ToList();
  17.  
  18.             List<string> empty = new List<string>();
  19.  
  20.             for (int i = 0; i < list.Count; i++)
  21.             {
  22.                 if (i % 2 == 1)
  23.                 {
  24.                     empty.Add(list[i]);
  25.                 }
  26.             }
  27.             Console.WriteLine(string.Join("",empty));
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement