Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class ArrayMatcher
- {
- static void Main()
- {
- string intput = Console.ReadLine();
- string[] splitedInput = intput.Split('\\');
- var array1 = splitedInput[0];
- var array2 = splitedInput[1];
- var newArray1 = array1.Except(array2);
- string[] sortedArray1 = newArray1.Select(c => c.ToString()).ToArray();
- Array.Sort(sortedArray1,StringComparer.Ordinal);
- var newArray2 = array2.Except(array1);
- string[] sortedArray2 = newArray2.Select(c => c.ToString()).ToArray();
- Array.Sort(sortedArray2,StringComparer.Ordinal);
- var bothArrays = array1 + array2;
- var set = new HashSet<string>();
- var duplicates = bothArrays
- .GroupBy(i => i)
- .Where(g => g.Count() > 1)
- .Select(g => g.Key);
- string[] sortedArrays = duplicates.Select(c => c.ToString()).ToArray();
- Array.Sort(sortedArrays,StringComparer.Ordinal);
- if (splitedInput[2] == "join")
- {
- foreach (var ch in sortedArrays)
- {
- Console.Write(ch);
- }
- Console.WriteLine();
- }
- else if (splitedInput[2] == "right exclude")
- {
- foreach (var ch in sortedArray1)
- {
- Console.Write(ch);
- }
- Console.WriteLine();
- }
- else if (splitedInput[2] == "left exclude")
- {
- foreach (var ch in sortedArray2)
- {
- Console.Write(ch);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement