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 Task37
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- string firstArray = "Первый массив: ";
- string secondArray = "Второй массив: ";
- string arrayValuesOutput = "Собранный массив: ";
- string arrayWithoutRepeatingElements = "Массив без повторяющихся элементов: ";
- int[] array;
- int[] array2;
- FillArray(out array, random);
- FillArray(out array2, random);
- Console.Write(firstArray);
- OutputArray(array);
- Console.Write(secondArray);
- OutputArray(array2);
- List<int> arrayValues = new List<int>();
- arrayValues.AddRange(array);
- arrayValues.AddRange(array2);
- Console.Write(arrayValuesOutput);
- OutputList(arrayValues);
- Console.WriteLine();
- RemoveDuplicateItems(ref arrayValues);
- Console.Write(arrayWithoutRepeatingElements);
- OutputList(arrayValues);
- }
- static void OutputList(List<int> arrayValues)
- {
- for (int i = 0; i < arrayValues.Count; i++)
- {
- Console.Write(arrayValues[i] + " ");
- }
- }
- static void RemoveDuplicateItems(ref List<int> arrayValues)
- {
- for (int i = 0; i < arrayValues.Count; i++)
- {
- for (int j = 0; j < arrayValues.Count; j++)
- {
- if (i != j && arrayValues[i] == arrayValues[j])
- {
- arrayValues.RemoveAt(i);
- }
- }
- }
- }
- static void OutputArray(int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- Console.WriteLine();
- }
- static void FillArray(out int[] array, Random random)
- {
- int minValueArray = 1;
- int maxValueArray = 10;
- array = new int[random.Next(minValueArray, maxValueArray)];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(minValueArray, maxValueArray);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement