Answer:
Check the explanation
Explanation:
using System;
using System.Collections.Generic;
using System.Linq;
public class Problem2
{
public static IEnumerable<int> merge (IEnumerable<int> input1, IEnumerable<int> input2, IEnumerable<int> input3)
{
IList<int> list = new List<int>();
foreach (int i in input1)
{
if(i%3==0 && ! list.Contains(i))
list.Add(i);
}
foreach (int i in input2)
{
if(i%3==0 && ! list.Contains(i))
list.Add(i);
}
foreach (int i in input3)
{
if(i%3==0 && ! list.Contains(i))
list.Add(i);
}
return list;
}
}
public class Problem2Demo{
static void Main (string[] args)
{
Random rnd = new Random ();
var list1 = Enumerable.Range (1, 10).Select (i => (rnd.Next () % 15) + 1);
var list2 = Enumerable.Range (1, 10).Select (i => (rnd.Next () % 15) + 1);
var list3 = Enumerable.Range (1, 10).Select (i => (rnd.Next () % 15) + 1);
var answer = Problem2.merge (list1, list2, list3);
foreach (int i in answer)
{
Console.WriteLine (i);
}
}
Kindly check the attached output image below.