skipter

List - delete element at Odd position

Jul 11th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 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. namespace ConsoleApp1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             List<string> words = Console.ReadLine().Split().ToList();
  13.             List<string> result = new List<string>();
  14.             for (int i = 0; i < words.Count; i++)
  15.             {
  16.                 if (i % 2 != 0)
  17.                 {
  18.                     result.Add(words[i]);
  19.                 }
  20.             }
  21.             Console.WriteLine(string.Join("", result));
  22.         }
  23.     }
  24. }
Add Comment
Please, Sign In to add comment