Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework37
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] array1 = { "1", "1", "2", "3", "3" };
- string[] array2 = { "3", "3", "4", "5", "5", "6", "7", "7" };
- List<string> list = new List<string>();
- AddUniqueElementsInList(array1, list);
- AddUniqueElementsInList(array2, list);
- Console.Write("Список, содержащий только уникальные элементы из двух массивов: ");
- OutputListElements(list);
- }
- static void OutputListElements(List<string> list)
- {
- for (int i = 0; i < list.Count; i++)
- {
- Console.Write(list[i] + " ");
- }
- }
- static void AddUniqueElementsInList(string[] array, List<string> list)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (list.Contains(array[i]) == false)
- {
- list.Add(array[i]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement