Advertisement
braveheart1989

Array_Matcher

Apr 12th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 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 _04.Array_Matcher
  8. {
  9.     class Array_Matcher
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] array = Console.ReadLine().Split('\\');
  14.             string[] newArray = new string[array.Length];
  15.             char[] array1 = array[0].ToCharArray();
  16.             char[] array2 = array[1].ToCharArray();
  17.             List<char> result = new List<char>();
  18.             for (int i = 0; i < array.Length-1; i++)
  19.             {
  20.                 if (array[2] == "join")
  21.                 {
  22.                     foreach (var item in array1)
  23.                     {
  24.                         if (array2.Contains(item))
  25.                         {
  26.                             result.Add(item);
  27.                         }
  28.                     }
  29.                 }
  30.                 else if (array[2]== "left exclude")
  31.                 {
  32.                     foreach (var item in array2)
  33.                     {
  34.                         if (!array1.Contains(item))
  35.                         {
  36.                             result.Add(item);
  37.                         }
  38.                     }
  39.                 }
  40.                 else
  41.                 {
  42.                     foreach (var item in array1)
  43.                     {
  44.                         if (!array2.Contains(item))
  45.                         {
  46.                             result.Add(item);
  47.                         }
  48.                     }
  49.                 }
  50.             }
  51.             result.Sort();
  52.             Console.WriteLine(string.Join("", result.Distinct()));
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement