Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace MixedUpLists
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> list1 = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> list2 = Console.ReadLine().Split().Select(int.Parse).Reverse().ToList();
- List<int> mixed = new List<int>();
- List<int> border = new List<int>();
- if (list1.Count > list2.Count)
- {
- for (int i = 0; i < list2.Count; i++)
- {
- mixed.Add(list1[i]);
- mixed.Add(list2[i]);
- }
- mixed.Sort();
- border.Add(list1[list1.Count - 2]);
- border.Add(list1[list1.Count - 1]);
- }
- else
- {
- for (int i = 0; i < list1.Count; i++)
- {
- mixed.Add(list1[i]);
- mixed.Add(list2[i]);
- }
- mixed.Sort();
- border.Add(list2[list2.Count - 2]);
- border.Add(list2[list2.Count - 1]);
- }
- for (int i = 0; i < mixed.Count; i++)
- {
- border.Sort();
- if (mixed[i] > border[0] && mixed[i] < border[1])
- {
- Console.Write(mixed[i] + " ");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment