Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Объединение_в_одну_коллекцию
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] firstArrayNumbers = new int[10];
- int[] secondArrayNumbers = new int[10];
- List<int> combinedValuesTwoArrays = new List<int>();
- Random random = new Random();
- FillArray(firstArrayNumbers, random);
- Console.Write("Первый массив: ");
- ShowInfo(firstArrayNumbers);
- FillArray(secondArrayNumbers, random);
- Console.Write("\nВторой массив: ");
- ShowInfo(secondArrayNumbers);
- CombineIntoCollection(firstArrayNumbers, combinedValuesTwoArrays);
- CombineIntoCollection(secondArrayNumbers, combinedValuesTwoArrays);
- Console.Write("\nОбъединённые массивы в коллекции: ");
- ShowInfo(combinedValuesTwoArrays);
- Console.WriteLine("\n");
- }
- static void FillArray(int[] array, Random random)
- {
- int MinimumRandomValue = 0;
- int MaximumRandomValue = 10;
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(MinimumRandomValue, MaximumRandomValue);
- }
- }
- static void CombineIntoCollection(int[] array, List<int> combinedValuesTwoArrays)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (!combinedValuesTwoArrays.Contains(array[i]))
- {
- combinedValuesTwoArrays.Add(array[i]);
- }
- }
- }
- static void ShowInfo(int[] array)
- {
- foreach (var number in array)
- {
- Console.Write(number + " ");
- }
- }
- static void ShowInfo(List<int> combinedValuesTwoArrays)
- {
- foreach (var number in combinedValuesTwoArrays)
- {
- Console.Write(number + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement