JustSteppedIn
BAN USER//For unique values in the resulting array..
using System;
using System.Linq;
class ArrayIntersection
{
static void Main()
{
int[] arr1 = { 1, 3, 6, 10, 3 };
int[] arr2 = { 2, 3, 5, 6, 3 };
int[] test = arr1.Intersect(arr2).ToArray(); // Gives {3, 6}
}
}
using System;
using System.Collections.Generic;
class SingularityFinder
{
static void Main()
{
int[] arr = {2,3,5,1,2,2,5,3,5,3 };
List<int> entries = new List<int>();
bool bl = false;
for (int i = 0; i < arr.Length - 1; i++)
{
bl = false;
if (!entries.Contains(arr[i]))
{
entries.Add(arr[i]);
for (int j = i + 1; j < arr.Length; j++)
{
if (arr[i] == arr[j])
{
bl = true;
break;
}
}
if (!bl)
{
Console.WriteLine(arr[i]);
bl = true;
break;
}
}
}
if (!bl)
{
Console.WriteLine(arr[arr.Length - 1]);
}
}
}
- JustSteppedIn November 06, 2014
- JustSteppedIn November 12, 2014