Advertisement
grubcho

Ununion lists_Lists

Jun 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 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 Ununion_lists
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<int> primal = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.             int n = int.Parse(Console.ReadLine());
  15.             int count = 0;
  16.             while (count < n)
  17.             {
  18.                 List<int> current = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  19.                 count++;
  20.                 foreach (int number in current)
  21.                 {
  22.                     if (!primal.Contains(number))
  23.                     {
  24.                         primal.Add(number);
  25.                     }
  26.                     else
  27.                     {
  28.                         primal.RemoveAll(a => a == number);
  29.                     }
  30.                 }            
  31.             }
  32.             primal.Sort();
  33.             Console.WriteLine(string.Join(" ", primal));
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement