stefan1919

Join Lists

Sep 8th, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 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 ConsoleApplication6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string inputFirst = Console.ReadLine();
  14.             string inputSecond = Console.ReadLine();
  15.             string[] arrayFirst = inputFirst.Split(' ');
  16.             string[] arraySecond = inputSecond.Split(' ');
  17.             List<int> final = new List<int>();
  18.             int counter = 0;
  19.             for (int i = 0; i < arrayFirst.Length; i++)
  20.             {
  21.              final.Add(int.Parse(arrayFirst[i]));
  22.              counter++;
  23.             }
  24.             for (int i = 0; i < arraySecond.Length; i++)
  25.             {
  26.              final.Add(int.Parse(arraySecond[i]));
  27.              counter++;
  28.             }
  29.             final.Sort();
  30.             bool b = false;
  31.             while (b != true)
  32.             {
  33.                 b = true;
  34.                 int p = 0;
  35.                 for (int i = 0; i < counter - 1; i++)
  36.             {
  37.                 if (final[i] == final[i + 1])
  38.                 {
  39.                     final.RemoveAt(i);
  40.                     counter--;
  41.                 }
  42.                 p = counter;
  43.             }
  44.                 for (int j = 0; j < p - 1; j++)
  45.                 {
  46.                     if (final[j] == final[j + 1])
  47.                     {
  48.                         b = false;
  49.                     }
  50.                 }
  51.             }
  52.             foreach (var item in final)
  53.             {
  54.                 Console.Write(item + " ");
  55.             }
  56.  
  57.  
  58.             }
  59.         }
  60.     }
Advertisement
Add Comment
Please, Sign In to add comment