Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace _02.Common_Elements
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Write a program, which prints common elements in two arrays. You have to compare the elements of the second array to the elements of the first.
- string[] array1 = Console.ReadLine().Split();
- string[] array2 = Console.ReadLine().Split();
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < array1.Length; i++)
- {
- for (int j = 0; j < array2.Length; j++)
- {
- if (array1[i] == array2[j])
- {
- result.Append(array2[j] + " ");
- }
- }
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement