neZnam121

Untitled

Oct 24th, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _03._Phone_Shop
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<string> phones = Console.ReadLine()
  12.                                    .Split(", ", StringSplitOptions.RemoveEmptyEntries)
  13.                                    .ToList();
  14.             string comad = Console.ReadLine();
  15.             string[] comand = comad.Split();
  16.  
  17.             if (comand[0] == "Add")
  18.             {
  19.                 phones.Add(comand[1]);
  20.             }
  21.              if ( comand[0] == "Remove")
  22.             {
  23.                 phones.Remove(comand[1]);
  24.             }
  25.              if (comand[0] == "Bonus phone")
  26.             {
  27.  
  28.                 for (int i = 0; i < phones.Count; i++)
  29.                 {
  30.                     if (phones[i].Contains(comand[2]))
  31.                     {
  32.                         phones[i] = comand[2];
  33.                     }
  34.                 }
  35.                
  36.             }
  37.              if (comand[0] == "Last")
  38.             {
  39.                 for (int i = 0; i < phones.Count; i++)
  40.                 {
  41.                     if (phones[i].Contains(comand[1]))
  42.                     {
  43.                         phones[phones.Count - 1] = comand[1];
  44.                     }
  45.                 }
  46.             }
  47.              if( comand[0] == "End")
  48.             {
  49.                 Console.WriteLine(string.Join(", ", phones));
  50.             }
  51.  
  52.         }
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment