Advertisement
dragonbs

Append Arrays

Feb 17th, 2023
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. class Program
  7. {
  8.     static void Main()
  9.     {
  10.         string[] inputArray = Console.ReadLine().Split('|').ToArray();
  11.         List<int> result = new List<int>();
  12.         for (int i = inputArray.Length - 1; i >= 0; i--)
  13.         {
  14.             char[] separators = { ' ' };
  15.             List<int> trimmedNums = inputArray[i]
  16.                     .Split(separators, StringSplitOptions.RemoveEmptyEntries)
  17.                     .Select(int.Parse)
  18.                     .ToList();
  19.             result.AddRange(trimmedNums);
  20.         }
  21.         Console.WriteLine(string.Join(" ", result));
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement