skipter icon

C# Integer Insertion / List convert + insert

skipter | PRO | 06/30/17 06:56:46 PM UTC | 0 ⭐ | 343 👁️ | Never ⏰ | []
C# |

670 B

|

None

|

0 👍

/

0 👎

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace _2.Integer_Insertion
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> elements = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
 
            string input = Console.ReadLine();
            while (input != "end")
            {
                int firstDigit = input[0] - '0';
                elements.Insert(firstDigit, int.Parse(input));
 
                input = Console.ReadLine();
            }
            Console.WriteLine(String.Join(" ", elements));
        }
    }
}

Comments