Advertisement
Dilyana86

Untitled

Jun 8th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace listsExercises
  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> list = Console.ReadLine().Split().Select(int.Parse).ToList();
  18.                
  19.                 for(int j=0; j<primal.Count; j++)
  20.                 {
  21.                     for(int k=0; k<list.Count; k++)
  22.                     {
  23.                         if (primal[j] == list[k])
  24.                         {
  25.                             primal.RemoveAt(j);
  26.                             list.RemoveAt(k);
  27.                             k = 0;
  28.                             j = 0;
  29.                         }
  30.                     }
  31.                 }
  32.                 primal.AddRange(list);
  33.                 primal.Sort();
  34.             }
  35.             Console.WriteLine(string.Join(" ", primal));
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement