Advertisement
a_tifonoff

Array Matcher

Mar 30th, 2015
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 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 ArrayMatcher
  8. {
  9.     class ArrayMatcher
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string inputDate = Console.ReadLine();
  14.             string[] date = inputDate.Split('\\');
  15.             char[] leftArray = date[0].ToCharArray();
  16.             char[] rightArray = date[1].ToArray();
  17.             List<char> output = new List<char>();
  18.             int flag = 0;
  19.             if (date[2] == "join")
  20.             {
  21.                 for (int i = 0; i < rightArray.Length; i++)
  22.                 {
  23.                     for (int j = 0; j < leftArray.Length; j++)
  24.                     {
  25.                         if (leftArray[j] == rightArray[i])
  26.                         {
  27.                             output.Add(leftArray[j]);
  28.                         }
  29.                     }
  30.                 }
  31.  
  32.  
  33.             }
  34.             else if (date[2] == "left exclude")
  35.             {
  36.                 for (int i = 0; i < rightArray.Length; i++)
  37.                 {
  38.                     for (int j = 0; j < leftArray.Length; j++)
  39.                     {
  40.                         if (rightArray[i] == leftArray[j])
  41.                         {
  42.                             flag++;
  43.                         }
  44.                        
  45.                     }
  46.                         if(flag==0)output.Add(rightArray[i]);
  47.                         flag = 0;
  48.                 }
  49.             }
  50.             else if (date[2] == "right exclude")
  51.             {
  52.                 for (int i = 0; i < leftArray.Length; i++)
  53.                 {
  54.                     for (int j = 0; j < rightArray.Length; j++)
  55.                     {
  56.                         if (leftArray[i] == rightArray[j])
  57.                         {
  58.                             flag++;
  59.                         }
  60.  
  61.                     }
  62.                     if (flag == 0) output.Add(leftArray[i]);
  63.                     flag = 0;
  64.                 }
  65.             }
  66.             output.Sort();
  67.             string outputString = string.Join("", output);
  68.             Console.WriteLine(outputString);
  69.  
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement