Advertisement
obedmarsh

05. Tear List in Half

Jun 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 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. using System.Text.RegularExpressions;
  7.  
  8. namespace Extended
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.  
  15.             List<string> list = Console.ReadLine().Split(' ').ToList();
  16.             List<string> bottom = new List<string>();
  17.             List<string> up = new List<string>();
  18.             List<string> res = new List<string>();
  19.  
  20.             int len = list.Count;
  21.  
  22.             for (int i = 0; i < len / 2; i++)
  23.             {
  24.                 bottom.Add(list[i]);
  25.             }
  26.  
  27.             for (int i = len / 2; i < len; i++)
  28.             {
  29.                 up.Add(list[i]);
  30.             }
  31.  
  32.             string re = string.Join("", up);
  33.  
  34.  
  35.             for (int i = 0; i < bottom.Count; i++)
  36.             {
  37.                 res.Add(re[i * 2].ToString());
  38.                 res.Add(bottom[i]);
  39.                 res.Add(re[i * 2 + 1].ToString());
  40.             }
  41.             Console.WriteLine(string.Join(" ", res));
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement