Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace ConsoleApp3
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string[] array1 = CreateArray();
- string[] array2 = CreateArray();
- List<string> numbers = new List<string>();
- CombineArrays(numbers, array1);
- CombineArrays(numbers, array2);
- PrintCombinedArrays(numbers);
- }
- static Random random = new Random();
- static string[] CreateArray()
- {
- int arrayLengthMin = 5;
- int arrayLengthMax = 10;
- int arrayLength = random.Next(arrayLengthMin, arrayLengthMax);
- string[] array = new string[arrayLength];
- int arrayValueMax = 11;
- for (int i = 0; i < array.Length; i++)
- array[i] = Convert.ToString(random.Next(arrayValueMax));
- return array;
- }
- static void CombineArrays(List<string> numbers, string[] array)
- {
- foreach (string number in array)
- if (numbers.Contains(number) == false)
- numbers.Add(number);
- }
- static void PrintCombinedArrays(List<string> numbers)
- {
- Console.Write("\nОбъединенный массив: ");
- foreach (string number in numbers)
- Console.Write(number + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement