Advertisement
silvi81

Array Matcher

Nov 14th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 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()
  12. {
  13. string[] input = Console.ReadLine().Split('\\');
  14. string one = input[0];
  15. string two = input[1];
  16.  
  17. List<char> result = new List<char>();
  18. if (input[2]== "join")
  19. {
  20. for (int i = 0; i < one.Length; i++)
  21. {
  22. if (two.Contains(one[i]))
  23. {
  24. result.Add(one[i]);
  25. }
  26. }
  27. result.Sort();
  28. for (int i = 0; i < result.Count; i++)
  29. {
  30. Console.Write(result[i]);
  31. }
  32. Console.WriteLine();
  33. }
  34. if (input[2] == "right exclude")
  35. {
  36. for (int i = 0; i < one.Length; i++)
  37. {
  38. if (!two.Contains(one[i]))
  39. {
  40. result.Add(one[i]);
  41. }
  42. }
  43. result.Sort();
  44. for (int i = 0; i < result.Count; i++)
  45. {
  46. Console.Write(result[i]);
  47. }
  48. Console.WriteLine();
  49. }
  50. if (input[2] == "left exclude")
  51. {
  52. for (int i = 0; i < two.Length; i++)
  53. {
  54. if (!one.Contains(two[i]))
  55. {
  56. result.Add(two[i]);
  57. }
  58. }
  59. result.Sort();
  60. for (int i = 0; i < result.Count; i++)
  61. {
  62. Console.Write(result[i]);
  63. }
  64. Console.WriteLine();
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement