Aliendreamer

half split list argument 5.Arrays

Jun 22nd, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 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 _05ListExcercisesTearListInHalf
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             List<int> InputTokens = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  15.             List<int> movedInts = new List<int>(InputTokens);
  16.  
  17.             int count = 0;
  18.             int remove = Math.Max(0, InputTokens.Count/2);
  19.             movedInts.RemoveRange(0,InputTokens.Count / 2);
  20.             InputTokens.RemoveRange((InputTokens.Count / 2),remove);
  21.             //input done TODO logic of spliting the digits and adding them to the List
  22.            
  23.                            
  24.            for(int i=0;i<movedInts.Count;i++)
  25.             {
  26.                 int result = movedInts[i];
  27.  
  28.                 for (;result != 0; result /= 10)
  29.                 {
  30.                     if (count == 0)
  31.                     {
  32.                         InputTokens.Insert((i * 3)+1, result%10);
  33.                         count++;
  34.  
  35.                     }
  36.                     else
  37.                     {
  38.                         InputTokens.Insert((i * 3) , result%10);
  39.                         count = 0;
  40.                     }
  41.                    
  42.                    
  43.                    
  44.                 }
  45.                
  46.  
  47.             }
  48.             Console.WriteLine(string.Join(" ",InputTokens));
  49.  
  50.  
  51.  
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment