Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Ijunior
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int arrayCapacity = 10;
- int[] array01 = new int[arrayCapacity];
- int[] array02 = new int[arrayCapacity];
- Random random = new Random();
- List<int> list = new List<int>();
- FillArray(array01, random);
- FillArray(array02, random);
- ShowArray(array01);
- ShowArray(array02);
- FillList(array01, list);
- FillList(array02, list);
- ShowList(list);
- }
- static void FillArray(int[] array, Random random)
- {
- int minRandomNumber = 1;
- int maxRandomNumber = 6;
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(minRandomNumber, maxRandomNumber);
- }
- }
- static void ShowArray(int[] array)
- {
- foreach (int number in array)
- {
- Console.Write(number + " ");
- }
- Console.WriteLine();
- }
- static void FillList(int[] array, List<int> list)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (list.Contains(array[i]) == false)
- {
- list.Add(array[i]);
- }
- }
- }
- static void ShowList(List<int> list)
- {
- foreach(int number in list)
- {
- Console.Write(number + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment