Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace IntegerInsertion
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> list1 = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- string input = Console.ReadLine();
- int x = 0;
- while (input != "end")
- {
- x = int.Parse(input);
- int firstDigit = GetFirstDigit(x);
- list1.Insert(firstDigit, x);
- input = Console.ReadLine();
- }
- for (int i = 0; i < list1.Count; i++)
- {
- Console.WriteLine(list1[i]);
- }
- }
- public static int GetFirstDigit(int input)
- {
- if (input < 10)
- {
- return input;
- }
- return GetFirstDigit((input - (input % 10)) / 10);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement