Advertisement
optybg

Untitled

Feb 19th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace AppendLists_Lab2
  7. {
  8.     public class AppendLists_Lab2
  9.     {
  10.         public static void Main()
  11.         {
  12.             var input = Console.ReadLine()
  13.                 .Split('|')
  14.                 .ToList();
  15.  
  16.             List<string> result = new List<string>();
  17.  
  18.             List<string> temp = new List<string>();
  19.  
  20.             for (int i = input.Count - 1; i >= 0; i--)
  21.             {
  22.                 temp = new List<string>(input[i].Split(' ').ToList());
  23.  
  24.                 for (int j = 0; j < temp.Count; j++)
  25.                 {
  26.                     if (temp[j].Length > 0)
  27.                     {
  28.                         temp.RemoveAt(j);
  29.                     }
  30.                 }
  31.  
  32.                 result.AddRange(temp);
  33.             }
  34.             foreach (var item in result)
  35.             {
  36.                 Console.Write(item + " ");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement