Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- int arrayLengthOne = 6;
- int arrayLengthTwo = 4;
- string[] arrayNumberOne = new string[arrayLengthOne];
- string[] arrayNumberTwo = new string[arrayLengthTwo];
- FillNumbers(arrayNumberOne);
- FillNumbers(arrayNumberTwo);
- Print(arrayNumberOne);
- Print(arrayNumberTwo);
- List<string> uniqueNumbers = new List<string>();
- JoinArray(uniqueNumbers, arrayNumberOne);
- JoinArray(uniqueNumbers, arrayNumberTwo);
- Console.WriteLine(string.Join(" ", uniqueNumbers));
- Console.ReadKey();
- }
- private static void FillNumbers(string[] array, int maxNumber = 6, int minNumber = 0)
- {
- Random random = new Random(DateTime.Now.Millisecond);
- int randomNumber;
- for (int i = 0; i < array.Length; i++)
- {
- randomNumber = random.Next(minNumber, maxNumber + 1);
- array[i] = randomNumber.ToString();
- }
- }
- private static void Print(string[] arrayNumber)
- {
- Console.WriteLine(String.Join(" ", arrayNumber));
- }
- private static void JoinArray(List<string> uniqueNumbers, string[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (uniqueNumbers.Contains(array[i]) == false)
- uniqueNumbers.Add(array[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement