static void Main() { string[] elementsToAdd = Console.ReadLine().Split(); int countOfRemoveOps = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); foreach (var elementToAdd in elementsToAdd) { Console.Write(addCollection.Add(elementToAdd) + " "); } Console.WriteLine(); foreach (var elementToAdd in elementsToAdd) { Console.Write(addRemoveCollection.Add(elementToAdd) + " "); } Console.WriteLine(); foreach (var elementToAdd in elementsToAdd) { Console.Write(myList.Add(elementToAdd) + " "); } Console.WriteLine(); for (int i = 0; i < countOfRemoveOps; i++) { Console.Write(addRemoveCollection.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < countOfRemoveOps; i++) { Console.Write(myList.Remove() + " "); } }
static void Main(string[] args) { string[] data = Console.ReadLine().Split(); IAdd addcollection = new AddCollection(); IAddRemove addRemoveCollection = new AddRemoveCollection(); IMyList mylist = new MyList(); List <int> result = new List <int>(); List <int> result1 = new List <int>(); List <int> result2 = new List <int>(); foreach (var item in data) { result.Add(addcollection.Add(item)); result1.Add(addRemoveCollection.Add(item)); result2.Add(mylist.Add(item)); } Console.WriteLine(string.Join(" ", result)); Console.WriteLine(string.Join(" ", result1)); Console.WriteLine(string.Join(" ", result2)); int n = int.Parse(Console.ReadLine()); List <string> a = new List <string>(); List <string> b = new List <string>(); for (int i = 0; i < n; i++) { a.Add((addRemoveCollection.Remove())); b.Add((mylist.Remove())); } Console.WriteLine(string.Join(" ", a)); Console.WriteLine(string.Join(" ", b)); }
public static void Main(string[] args) { var itemsToAdd = Console.ReadLine().Split().ToArray(); int removeOperations = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); foreach (var item in itemsToAdd) { Console.Write($"{addCollection.Add(item)} "); } Console.WriteLine(); foreach (var item in itemsToAdd) { Console.Write($"{addRemoveCollection.Add(item)} "); } Console.WriteLine(); foreach (var item in itemsToAdd) { Console.Write($"{myList.Add(item)} "); } Console.WriteLine(); for (int i = 0; i < removeOperations; i++) { Console.Write($"{addRemoveCollection.Remove()} "); } Console.WriteLine(); for (int i = 0; i < removeOperations; i++) { Console.Write($"{myList.Remove()} "); } }
public static void Main() { string[] elementsToAdd = Console.ReadLine().Split(); int countOfRemoveOps = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); printIndexs(elementsToAdd, addCollection, addRemoveCollection, myList); Console.WriteLine(); for (int i = 0; i < countOfRemoveOps; i++) { Console.Write(addRemoveCollection.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < countOfRemoveOps; i++) { Console.Write(myList.Remove() + " "); } Console.WriteLine(); }
public static void Main() { IAddCollection <string> addColletion = new AddCollection <string>(); IAddRemoveCollection <string> addRemCollection = new AddRemoveCollection <string>(); IMyList <string> myList = new MyList <string>(); var itemsToAdd = Console.ReadLine().Split(' '); var removeOperationsCount = int.Parse(Console.ReadLine()); var addCollAddIndexes = new StringBuilder(); var addRemCollAddIndexes = new StringBuilder(); var myListCollAddIndexes = new StringBuilder(); foreach (var item in itemsToAdd) { addCollAddIndexes.Append($"{addColletion.Add(item)} "); addRemCollAddIndexes.Append($"{addRemCollection.Add(item)} "); myListCollAddIndexes.Append($"{myList.Add(item)} "); } var addRemCollRemoveElements = new StringBuilder(); var myListRemoveElements = new StringBuilder(); for (int i = 0; i < removeOperationsCount; i++) { addRemCollRemoveElements.Append($"{addRemCollection.Remove()} "); myListRemoveElements.Append($"{myList.Remove()} "); } Console.WriteLine(addCollAddIndexes.ToString().Trim()); Console.WriteLine(addRemCollAddIndexes.ToString().Trim()); Console.WriteLine(myListCollAddIndexes.ToString().Trim()); Console.WriteLine(addRemCollRemoveElements.ToString().Trim()); Console.WriteLine(myListRemoveElements.ToString().Trim()); }