Created
May 19, 2024 17:51
-
-
Save Silence2100/f70811f6e5d126545aef6fc32ef5aa88 to your computer and use it in GitHub Desktop.
Объединение в одну коллекцию
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace Task003 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string[] words1 = new string[] {"привет", "пока", "собака", "кошка", "привет"}; | |
string[] words2 = new string[] {"кошка", "лошадь", "корова", "пока"}; | |
List<string> allWords = new List<string>(); | |
AddInList(allWords, words1); | |
AddInList(allWords, words2); | |
PrintList(allWords); | |
} | |
static void AddInList(List<string> allNumbers, string[] numbers) | |
{ | |
for (int i = 0; i < numbers.Length; i++) | |
{ | |
if (allNumbers.Contains(numbers[i]) == false) | |
{ | |
allNumbers.Add(numbers[i]); | |
} | |
} | |
} | |
static void PrintList(List<string> words) | |
{ | |
foreach (string word in words) | |
{ | |
Console.Write(word + " "); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment