Teo_Yanchev

1

Oct 4th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace _2._Common_Elements
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string[] arr = Console.ReadLine().Split().ToArray();
  11. string[] arr2 = Console.ReadLine().Split().ToArray();
  12. List<string> match = new List<string>();
  13. for (int i = 0; i < arr2.Length; i++)
  14. {
  15. for (int j = 0; j < arr.Length; j++)
  16. {
  17. if (arr[i] == arr2[j])
  18. {
  19. match.Add(arr2[j]);
  20. break;
  21. }
  22. }
  23. }
  24. Console.WriteLine(string.Join(" ", match));
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment