Zlobin2021

Collection

Mar 13th, 2022 (edited)
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Сollection
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             List<string> product = new List<string>();
  11.  
  12.             string[] set1 = new string[] { "Картошка", "Лук", "Морковь", "Греча", "Сметана", "Пикули", "Помидоры" };
  13.             string[] set2 = new string[] { "Сметана", "Мясо", "Сухарики", "Рис", "Лук", "Помидоры", "Майонез" };
  14.  
  15.             for (int i = 0; i < set1.Length; i++)
  16.             {
  17.                 if (product.Contains(set1[i]) == false)
  18.                 {
  19.                     product.Add(set1[i]);
  20.                 }
  21.             }
  22.  
  23.             for (int i = 0; i < set2.Length; i++)
  24.             {
  25.                 if (product.Contains(set2[i]) == false)
  26.                 {
  27.                     product.Add(set2[i]);
  28.                 }
  29.             }
  30.  
  31.             for (int i = 0; i < product.Count; i++)
  32.             {
  33.                 Console.WriteLine(product[i]);
  34.             }
  35.  
  36.             Console.WriteLine();
  37.         }
  38.     }
  39. }
Add Comment
Please, Sign In to add comment