Advertisement
ivanov_ivan

ArrayMatcher

Nov 9th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace HW16.ArrayMatcher
  9.     {
  10.     class ArrayMatcher
  11.         {
  12.         static void Main()
  13.             {
  14.             string[] input = Console.ReadLine().Split('\\');
  15.             string charValues = null;
  16.             char[] output = null;
  17.             if (input[2] == "join")
  18.                 {
  19.                 foreach (char item in input[0])
  20.                     {
  21.                     foreach (var item1 in input[1])
  22.                         {
  23.                         if (item == item1)
  24.                             {
  25.                             charValues = charValues + (char)item;
  26.                             }
  27.                         }
  28.                     }
  29.                 output = charValues.ToCharArray();
  30.                 Array.Sort(output);
  31.                 Console.WriteLine(output);
  32.                 }
  33.             if (input[2] == "right exclude")
  34.                 {
  35.                 foreach (var item in input[0])
  36.                     {
  37.                     if (input[1].Contains(item) == false)
  38.                         {
  39.                         charValues = charValues + item;
  40.                         }
  41.                     }
  42.                 output = charValues.ToCharArray();
  43.                 Array.Sort(output);
  44.                 Console.WriteLine(output);
  45.                 }
  46.             if (input[2] == "left exclude")
  47.                 {
  48.                 foreach (var item in input[1])
  49.                     {
  50.                     if (input[0].Contains(item) == false)
  51.                         {
  52.                         charValues = charValues + item;
  53.                         }
  54.                     }
  55.                 output = charValues.ToCharArray();
  56.                 Array.Sort(output);
  57.                 Console.WriteLine(output);
  58.                 }
  59.             }
  60.         }
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement