kwest87

Untitled

Apr 22nd, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp20
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int[] numbers1 = { 5, 2, 2 };
  15.             int[] numbers2 = { 5, 1, 1 };
  16.             HashSet<int> numbersList = new HashSet<int>();
  17.             AddNumbers(numbers1, numbersList);
  18.             AddNumbers(numbers2, numbersList);
  19.             ShowNumbers(numbersList);
  20.         }
  21.  
  22.         static void AddNumbers(int[] numbers, HashSet<int> numbersList)
  23.         {
  24.             for (int i = 0; i < numbers.Length; i++)
  25.             {
  26.                 numbersList.Add(numbers[i]);
  27.             }
  28.         }
  29.  
  30.         static void ShowNumbers(HashSet<int> numbersList)
  31.         {
  32.             foreach (int number in numbersList)
  33.                 Console.WriteLine(number);
  34.  
  35.         }
  36.     }
  37. }
  38. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment