Advertisement
North_Point

TearListInHalf

Jun 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 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.  
  7. namespace _05.Tear_List_in_Half
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.  
  15.             List<int> firstList = new List<int>();
  16.             List<int> secondList = new List<int>();
  17.  
  18.             List<int> fullList = new List<int>();
  19.             var first = 0;
  20.             var last = 0;
  21.  
  22.             for (int i = 0; i < input.Count/ 2; i++)
  23.             {
  24.                 firstList.Add(input[i]);
  25.             }
  26.             for (int i = input.Count / 2; i < input.Count; i++)
  27.             {
  28.                 secondList.Add(input[i]);
  29.             }
  30.             for (int i = 0; i < input.Count / 2; i++)
  31.             {
  32.                 first = secondList[i] / 10;
  33.                 last = secondList[i] % 10;
  34.  
  35.                 fullList.Add(first);
  36.                 fullList.Add(firstList[i]);
  37.                 fullList.Add(last);
  38.             }
  39.             Console.WriteLine(String.Join(" ",fullList ));
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement