2.Common Elements-Excercise
Моля Ви се помогнете! Нямам си идея как да реша задача 2.Common Elements.Ако може да ми дадете решението насоки или нещо такова,моля.
Линк към Judge: https://judge.softuni.bg/Contests/Compete/Index/1206#1
Моля Ви се помогнете! Нямам си идея как да реша задача 2.Common Elements.Ако може да ми дадете решението насоки или нещо такова,моля.
Линк към Judge: https://judge.softuni.bg/Contests/Compete/Index/1206#1
Ето и моето решение. :)
using System;
namespace CommonElements
{
class Program
{
static void Main(string[] args)
{
string[] firstCollection = Console.ReadLine().Split(" ");
string[] secondCollection = Console.ReadLine().Split(" ");
for (int k = 0; k < secondCollection.Length; k++)
{
for (int i = 0; i < firstCollection.Length; i++)
{
if (firstCollection[i] == secondCollection[k] &&
firstCollection[i] != null && secondCollection[k] != null)
{
Console.Write(firstCollection[i] + " ");
firstCollection[i] = null;
secondCollection[k] = null;
}
}
}
}
}
}