Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _2._Common_Elements
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] arr = Console.ReadLine().Split().ToArray();
- string[] arr2 = Console.ReadLine().Split().ToArray();
- List<string> match = new List<string>();
- for (int i = 0; i < arr2.Length; i++)
- {
- for (int j = 0; j < arr.Length; j++)
- {
- if (arr[i] == arr2[j])
- {
- match.Add(arr2[j]);
- break;
- }
- }
- }
- Console.WriteLine(string.Join(" ", match));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment