Advertisement
Guest User

04. Array Matcher

a guest
Mar 30th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6.  
  7. class Program
  8. {
  9.     static void Main()
  10.     {
  11.         string [] inp = Console.ReadLine().Split('\\');
  12.         char []  FirstArr = new char [inp[0].Length];
  13.         char[] SecondArr = new char[inp[1].Length];
  14.         List<char> Output = new List<char>();
  15.         string word = "";      
  16.  
  17.         string command = inp[2];
  18.         string firstWord = inp[0];
  19.         string SecondWord = inp[1];
  20.         for (int i = 0; i < firstWord.Length; i++)
  21.         {
  22.             FirstArr[i] = firstWord[i];
  23.            
  24.         }
  25.         for (int i = 0; i < SecondWord.Length; i++)
  26.         {
  27.             SecondArr[i] = SecondWord[i];
  28.  
  29.  
  30.         }
  31.         if (command =="join")
  32.         {
  33.             for (int i = 0; i < FirstArr.Length; i++)
  34.             {
  35.                 for (int j = 0; j < SecondArr.Length; j++)
  36.                 {
  37.                     if (FirstArr[i] ==SecondArr[j])
  38.                     {
  39.                         word += FirstArr[i];
  40.                     }
  41.                 }
  42.             }
  43.  
  44.         }
  45.         if (command == "right exclude")
  46.         {
  47.             for (int i = 0; i < FirstArr.Length; i++)
  48.             {
  49.                 for (int j = 0; j < SecondArr.Length; j++)
  50.                 {
  51.                     if (FirstArr[i] == SecondArr[j])
  52.                     {
  53.                         break;
  54.                     }
  55.                     else if (j == SecondArr.Length - 1)
  56.                     {
  57.                         word += FirstArr[i];
  58.                     }
  59.                 }
  60.             }
  61.         }
  62.         if (command == "left exclude")
  63.         {
  64.             for (int i = 0; i < SecondArr.Length; i++)
  65.             {
  66.                 for (int j = 0; j < FirstArr.Length; j++)
  67.                 {
  68.                     if (SecondArr[i] == FirstArr[j])
  69.                     {
  70.                         break;
  71.                     }
  72.                     else if (j == FirstArr.Length - 1)
  73.                     {
  74.                         word+= "" + SecondArr[i];
  75.                     }
  76.                 }
  77.             }
  78.         }
  79.         char[] result = word.ToCharArray();
  80.         Array.Sort<char>(result);
  81.         foreach (var item in result)
  82.         {
  83.             Console.Write(item);
  84.         }
  85.            
  86.        
  87.            
  88.        
  89.  
  90.  
  91.  
  92.  
  93.  
  94.     }
  95.  
  96.  
  97.  
  98.     private static void printArr(List<char> FirstArr)
  99.     {
  100.         foreach (var item in FirstArr)
  101.         {
  102.             Console.WriteLine(item);
  103.         }
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement