Advertisement
YavorGrancharov

Ununion_Lists

Jun 30th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Ununion_Lists
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<int> primal = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  12.  
  13.             int n = int.Parse(Console.ReadLine());
  14.  
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 List<int> sequence = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  18.  
  19.                 for (int j = 0; j < sequence.Count; j++)
  20.                 {
  21.                     if (primal.Contains(sequence[j]))
  22.                     {
  23.                         primal.Remove(sequence[j]);
  24.                     }
  25.                     else if (!primal.Contains(sequence[j]))
  26.                     {
  27.                         primal.Add(sequence[j]);
  28.                     }
  29.                 }
  30.             }
  31.             primal.Sort();
  32.             Console.WriteLine(string.Join(" ", primal));
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement