BorislavBorisov

Tasк.Intersection премахване само на повтарящите думи

Oct 11th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. /*Hristo Hristo Nakov Nakov Petya
  4. Nakov Vanessa Maria
  5.  output Hristo Hristo Petya
  6. */
  7. class Intersection
  8. {
  9.     static void Main()
  10.     {
  11.         List<string> listOne = new List<string>(Console.ReadLine().Split(' '));
  12.         List<string> listTwo = new List<string>(Console.ReadLine().Split(' '));
  13.  
  14.         listOne = IntersectionWord(listOne, listTwo);
  15.         foreach (var i in listOne)
  16.         {
  17.             Console.Write(i + " ");
  18.         }
  19.         Console.WriteLine();
  20.     }
  21.     static List<string> IntersectionWord(List<string> listOne, List<string> listTwo)
  22.     {
  23.         List<string> newL = new List<string>();
  24.         foreach (var i in listOne)
  25.         {
  26.             if(listTwo.Contains(i))
  27.             {
  28.                 continue;
  29.             }
  30.             newL.Add(i);
  31.         }
  32.         return newL;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment