Krasimir_Slavov

Untitled

Mar 8th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 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 Exam_4.Mixed_up_Lists
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> input_1 = Console.ReadLine().Split().Select(int.Parse).ToList();
  14.             List<int> input_2 = Console.ReadLine().Split().Select(int.Parse).ToList();
  15.             List<int> rule = new List<int>();
  16.             List<int> maxList = new List<int>();
  17.             List<int> mixedList = new List<int>();
  18.             if (input_1.Count > input_2.Count)
  19.             {
  20.                 maxList = input_1;
  21.             }
  22.             else
  23.             {
  24.                 maxList = input_2;
  25.                 maxList.Reverse();
  26.             }
  27.             for (int i = maxList.Count - 2; i < maxList.Count; i++)
  28.             {
  29.                 rule.Add(maxList[i]);
  30.             }
  31.             rule.Sort();
  32.             if (input_1.Count > input_2.Count)
  33.             {
  34.                 input_1.RemoveRange(input_1.Count - 2, 2);
  35.                 input_2.Reverse();
  36.             }
  37.             else
  38.             {
  39.                 input_2.RemoveRange(input_2.Count - 2, 2);
  40.                 input_2.Reverse();
  41.             }
  42.             for (int i = 0; i < input_1.Count; i++)
  43.             {
  44.                 mixedList.Add(input_1[i]);
  45.                 mixedList.Add(input_2[i]);
  46.             }
  47.             List<int> output = mixedList.FindAll(x => x > rule[0] && x < rule[1]);
  48.             output.Sort();
  49.             Console.WriteLine(string.Join(" ", output));
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment