// See https://aka.ms/new-console-template for more information class RandomRemoval { public static void Main() { int[] listA = new int[] { 1, 1, 1, 2, 2, 3, 5, 8, 13, 22, 35, 45, 68, 72, 90 }; int[] listB = new int[] { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 90 }; ArrayComparison(listA, listB); } public static void outputFromArray(int[] array) { for(int i=0; i < array.Length; i++) { Console.WriteLine("Duplicate element {0}: {1}", i, array[i]); Console.WriteLine(array[i]); } } public static void ArrayComparison(int[] primaryArray, int[] secondaryArray) { int duplicateArrayLength; int duplicateCount = 0; int matchItem; if (primaryArray.Length > secondaryArray.Length) { duplicateArrayLength = primaryArray.Length; } else { duplicateArrayLength = secondaryArray.Length; } int[] duplicates = new int[duplicateArrayLength]; for (int i = 0; i < primaryArray.Length; i++) { for (int j = 0; j < secondaryArray.Length; j++) if(primaryArray[i] == secondaryArray[j]) { matchItem = primaryArray[i]; if (!duplicates.Contains(matchItem)) { duplicateCount++; } else { break; } duplicates[duplicateCount] = matchItem; } } } public static int[] RandomArray(int length, int exclusiveUpperGenerationBound) { Random randomNumberGenerator = new Random(); int[] randomArray = new int[length]; for (int i = 0; i < randomArray.Length; i++) { int generatedValue; generatedValue = randomNumberGenerator.Next(exclusiveUpperGenerationBound); randomArray[i] = generatedValue; Console.WriteLine("Element {0} with value of {1} generated", i, generatedValue); } return randomArray; } }