Advertisement
skipter

C# Integer Insertion / List convert + insert

Jun 30th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 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 _2.Integer_Insertion
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> elements = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.  
  15.             string input = Console.ReadLine();
  16.             while (input != "end")
  17.             {
  18.                 int firstDigit = input[0] - '0';
  19.                 elements.Insert(firstDigit, int.Parse(input));
  20.  
  21.                 input = Console.ReadLine();
  22.             }
  23.             Console.WriteLine(String.Join(" ", elements));
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement