Advertisement
skipter

C# Append and reverse List with diff Split

Jun 23rd, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace _2.Append_List
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var values = Console.ReadLine().Split('|').ToList();
  11.             var result = new List<int>();
  12.  
  13.             for (int cnt = 0; cnt < values.Count; cnt++)
  14.             {
  15.                 var index = values[cnt].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
  16.                 index.Reverse();
  17.                 foreach (var num in index)
  18.                 {
  19.                     result.Add(num);
  20.                 }
  21.             }
  22.             result.Reverse();
  23.             Console.WriteLine(string.Join(" ", result));
  24.         }    
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement