Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03._Phone_Shop
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> phones = Console.ReadLine()
- .Split(", ", StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- string comad = Console.ReadLine();
- string[] comand = comad.Split();
- if (comand[0] == "Add")
- {
- phones.Add(comand[1]);
- }
- if ( comand[0] == "Remove")
- {
- phones.Remove(comand[1]);
- }
- if (comand[0] == "Bonus phone")
- {
- for (int i = 0; i < phones.Count; i++)
- {
- if (phones[i].Contains(comand[2]))
- {
- phones[i] = comand[2];
- }
- }
- }
- if (comand[0] == "Last")
- {
- for (int i = 0; i < phones.Count; i++)
- {
- if (phones[i].Contains(comand[1]))
- {
- phones[phones.Count - 1] = comand[1];
- }
- }
- }
- if( comand[0] == "End")
- {
- Console.WriteLine(string.Join(", ", phones));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment