private static void RemoveElements(AddRemoveCollection addRemoveCollection, MyList myList) { int removeOperations = int.Parse(Console.ReadLine()); for (int i = 0; i < removeOperations; i++) { if (i == removeOperations - 1) { Console.Write(addRemoveCollection.Remove()); } else { Console.Write(addRemoveCollection.Remove() + " "); } } Console.WriteLine(); for (int i = 0; i < removeOperations; i++) { if (i == removeOperations - 1) { Console.Write(myList.Remove()); } else { Console.Write(myList.Remove() + " "); } } Console.WriteLine(); }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(); int removeOperations = int.Parse(Console.ReadLine()); AddCollection <string> myAddColl = new AddCollection <string>(); AddRemoveCollection <string> myAddRemoveColl = new AddRemoveCollection <string>(); MyList <string> myList = new MyList <string>(); List <int> addIndexes = new List <int>(); List <int> addRemoveIndexes = new List <int>(); List <int> myListIndexes = new List <int>(); for (int index = 0; index < input.Length; index++) { addIndexes.Add(myAddColl.Add(input[index])); addRemoveIndexes.Add(myAddRemoveColl.Add(input[index])); myListIndexes.Add(myList.Add(input[index])); } List <string> addRemoves = new List <string>(); List <string> myListRemoves = new List <string>(); for (int removeIndex = 0; removeIndex < removeOperations; removeIndex++) { addRemoves.Add(myAddRemoveColl.Remove()); myListRemoves.Add(myList.Remove()); } Console.WriteLine(string.Join(" ", addIndexes)); Console.WriteLine(string.Join(" ", addRemoveIndexes)); Console.WriteLine(string.Join(" ", myListIndexes)); Console.WriteLine(string.Join(" ", addRemoves)); Console.WriteLine(string.Join(" ", myListRemoves)); }
static void Main(string[] args) { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); string[] elements = Console.ReadLine().Split(); int count = int.Parse(Console.ReadLine()); List <int> addCollectionResults = new List <int>(); List <int> addRemoveCollectionResults = new List <int>(); List <int> myListResults = new List <int>(); List <string> addRemoveCollectionRemoves = new List <string>(); List <string> myListRemoves = new List <string>(); foreach (string element in elements) { addCollectionResults.Add(addCollection.Add(element)); addRemoveCollectionResults.Add(addRemoveCollection.Add(element)); myListResults.Add(myList.Add(element)); } for (int counter = 0; counter < count; counter++) { addRemoveCollectionRemoves.Add(addRemoveCollection.Remove()); myListRemoves.Add(myList.Remove()); } Console.WriteLine(string.Join(" ", addCollectionResults)); Console.WriteLine(string.Join(" ", addRemoveCollectionResults)); Console.WriteLine(string.Join(" ", myListResults)); Console.WriteLine(string.Join(" ", addRemoveCollectionRemoves)); Console.WriteLine(string.Join(" ", myListRemoves)); }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(); int removedOperationsNumber = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); List <int> addCollectionResults = new List <int>(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); List <int> addRemoveCollectonAddResults = new List <int>(); List <string> addRemoveCollectionRemoveResults = new List <string>(); MyList myList = new MyList(); List <int> myListAddResults = new List <int>(); List <string> myListRemoveResults = new List <string>(); foreach (var item in input) { addCollectionResults.Add(addCollection.Add(item)); addRemoveCollectonAddResults.Add(addRemoveCollection.Add(item)); myListAddResults.Add(myList.Add(item)); } for (int i = 0; i < removedOperationsNumber; i++) { addRemoveCollectionRemoveResults.Add(addRemoveCollection.Remove()); myListRemoveResults.Add(myList.Remove()); } Console.WriteLine(string.Join(" ", addCollectionResults)); Console.WriteLine(string.Join(" ", addRemoveCollectonAddResults)); Console.WriteLine(string.Join(" ", myListAddResults)); Console.WriteLine(string.Join(" ", addRemoveCollectionRemoveResults)); Console.WriteLine(string.Join(" ", myListRemoveResults)); }
public static void Main(string[] args) { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var input = Console.ReadLine().Split(' '); var removeCount = int.Parse(Console.ReadLine()); foreach (var item in input) { Console.Write(addCollection.Add(item) + " "); } Console.WriteLine(); foreach (var item in input) { Console.Write(addRemoveCollection.Add(item) + " "); } Console.WriteLine(); foreach (var item in input) { Console.Write(myList.Add(item) + " "); } Console.WriteLine(); for (int i = 0; i < removeCount; i++) { Console.Write(addRemoveCollection.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < removeCount; i++) { Console.Write(myList.Remove() + " "); } }
static void Main(string[] args) { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); var firstSbCollection = new StringBuilder(); var secondSbCollection = new StringBuilder(); var thirdSbCollection = new StringBuilder(); var firstRemoveItems = new StringBuilder(); var secondRemoveItems = new StringBuilder(); var collection = Console.ReadLine() .Split(' ') .ToList(); for (int i = 0; i < collection.Count; i++) { firstSbCollection.Append(addCollection.Add(collection[i]) + " "); secondSbCollection.Append(addRemoveCollection.Add(collection[i]) + " "); thirdSbCollection.Append(myList.Add(collection[i]) + " "); } var numberOfRemovedItems = int.Parse(Console.ReadLine()); for (int i = 0; i < numberOfRemovedItems; i++) { firstRemoveItems.Append(addRemoveCollection.Remove() + " "); secondRemoveItems.Append(myList.Remove() + " "); } Console.WriteLine(firstSbCollection); Console.WriteLine(secondSbCollection); Console.WriteLine(thirdSbCollection); Console.WriteLine(firstRemoveItems); Console.WriteLine(secondRemoveItems); }
private static void Main() { string[] elements = Console.ReadLine().Split(); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); foreach (string element in elements) { addCollection.Add(element); addRemoveCollection.Add(element); myList.Add(element); } Console.WriteLine(addCollection.AddIndexes); Console.WriteLine(addRemoveCollection.AddIndexes); Console.WriteLine(myList.AddIndexes); int elementToRemove = int.Parse(Console.ReadLine()); for (int i = 1; i <= elementToRemove; i++) { addRemoveCollection.Remove(); myList.Remove(); } Console.WriteLine(addRemoveCollection.RemovedElements); Console.WriteLine(myList.RemovedElements); }
public static void Main() { var elementsToAdd = Console.ReadLine().Split().ToList(); var countOfRemoveOps = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveColletion = 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(addRemoveColletion.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(addRemoveColletion.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < countOfRemoveOps; i++) { Console.Write(myList.Remove() + " "); } Console.WriteLine(); }
public static void Main() { IAddCollection <string> addColection = new AddCollection <string>(); IAddRemoveCollection <string> addRemoveColection = new AddRemoveCollection <string>(); IMyList <string> myList = new MyList <string>(); var addCollIndexes = new StringBuilder(); var addRemCollIndexes = new StringBuilder(); var myListIndexes = new StringBuilder(); var tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var elem in tokens) { addCollIndexes.Append($"{addColection.Add(elem)} "); addRemCollIndexes.Append($"{addRemoveColection.Add(elem)} "); myListIndexes.Append($"{myList.Add(elem)} "); } var addRemcCollRemovedItems = new StringBuilder(); var myListRemovedItems = new StringBuilder(); var removeCount = int.Parse(Console.ReadLine()); for (int i = 0; i < removeCount; i++) { addRemcCollRemovedItems.Append($"{addRemoveColection.Remove()} "); myListRemovedItems.Append($"{myList.Remove()} "); } Console.WriteLine(addCollIndexes.ToString().Trim()); Console.WriteLine(addRemCollIndexes.ToString().Trim()); Console.WriteLine(myListIndexes.ToString().Trim()); Console.WriteLine(addRemcCollRemovedItems.ToString().Trim()); Console.WriteLine(myListRemovedItems.ToString().Trim()); }
public static void Main() { AddCollection <string> addCollection = new AddCollection <string>(); AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>(); MyList <string> mylist = new MyList <string>(); StringBuilder addOpsAddcollection = new StringBuilder(); StringBuilder addOpsAddRemoveCollection = new StringBuilder(); StringBuilder addOpsMylist = new StringBuilder(); StringBuilder removeAddRemoveCollection = new StringBuilder(); StringBuilder removeOpsMyList = new StringBuilder(); string[] tokens = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int removeOpsCount = int.Parse(Console.ReadLine()); foreach (string item in tokens) { addOpsAddcollection.Append(addCollection.Add(item) + " "); addOpsAddRemoveCollection.Append(addRemoveCollection.Add(item) + " "); addOpsMylist.Append(mylist.Add(item) + " "); } for (int i = 0; i < removeOpsCount; i++) { removeAddRemoveCollection.Append(addRemoveCollection.Remove() + " "); removeOpsMyList.Append(mylist.Remove() + " "); } PrintResult(addOpsAddcollection, addOpsAddRemoveCollection, addOpsMylist, removeAddRemoveCollection, removeOpsMyList); }
public void Run() { string[] input = Console .ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < input.Length; i++) { addCollectionItems.Add(input[i]); addRemoveCollectionItems.Add(input[i]); myListItems.Add(input[i]); } addCollectionItems.PrintAddedIndexes(); addRemoveCollectionItems.PrintAddedIndexes(); myListItems.PrintAddedIndexes(); int itemsToRemove = int.Parse(Console.ReadLine()); for (int i = 0; i < itemsToRemove; i++) { addRemoveCollectionItems.Remove(); myListItems.Remove(); } myListItems.PrintRemovedItems(); addRemoveCollectionItems.PrintRemovedItems(); }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); int countElementsToRemove = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); List <int> resultAddCollection = new List <int>(); List <int> resultAddRemoveCollection = new List <int>(); List <int> resultMyList = new List <int>(); List <string> resultRemovedAddRemoveCollection = new List <string>(); List <string> resultRenovedMyList = new List <string>(); for (int i = 0; i < input.Length; i++) { resultAddCollection.Add(addCollection.Add(input[i])); resultAddRemoveCollection.Add(addRemoveCollection.Add(input[i])); resultMyList.Add(myList.Add(input[i])); } for (int i = 0; i < countElementsToRemove; i++) { resultRemovedAddRemoveCollection.Add(addRemoveCollection.Remove()); resultRenovedMyList.Add(myList.Remove()); } Console.WriteLine(string.Join(' ', resultAddCollection)); Console.WriteLine(string.Join(' ', resultAddRemoveCollection)); Console.WriteLine(string.Join(' ', resultMyList)); Console.WriteLine(string.Join(' ', resultRemovedAddRemoveCollection)); Console.WriteLine(string.Join(' ', resultRenovedMyList)); }
public static void Main() { IAddable addCollection = new AddCollection(); ICollection addRemoveCollection = new AddRemoveCollection(); IMyList myList = new MyList(); string[] itemsForInsert = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder addCollectionAddOperationResults = new StringBuilder(); StringBuilder addRemoveCollectionAddOperationResults = new StringBuilder(); StringBuilder myListAddOperationResults = new StringBuilder(); foreach (var item in itemsForInsert) { addCollectionAddOperationResults.Append(addCollection.Add(item) + " "); addRemoveCollectionAddOperationResults.Append(addRemoveCollection.Add(item) + " "); myListAddOperationResults.Append(myList.Add(item) + " "); } Console.WriteLine(addCollectionAddOperationResults.ToString().Trim()); Console.WriteLine(addRemoveCollectionAddOperationResults.ToString().Trim()); Console.WriteLine(myListAddOperationResults.ToString().Trim()); StringBuilder addRemoveCollectionRemoveOperationResults = new StringBuilder(); StringBuilder myListRemoveOperationResults = new StringBuilder(); int numberOfRemoveOperations = int.Parse(Console.ReadLine()); for (int i = 0; i < numberOfRemoveOperations; i++) { addRemoveCollectionRemoveOperationResults.Append(addRemoveCollection.Remove() + " "); myListRemoveOperationResults.Append(myList.Remove() + " "); } Console.WriteLine(addRemoveCollectionRemoveOperationResults.ToString().Trim()); Console.WriteLine(myListRemoveOperationResults.ToString().Trim()); }
public void Run() { string[] input = Console.ReadLine().Split(); int removeCount = int.Parse(Console.ReadLine()); for (int i = 0; i < input.Length; i++) { Console.Write(addCollection.Add(input[i]) + " "); } Console.WriteLine(); for (int i = 0; i < input.Length; i++) { Console.Write(addRemoveCollection.Add(input[i]) + " "); } Console.WriteLine(); for (int i = 0; i < input.Length; i++) { Console.Write(myList.Add(input[i]) + " "); } Console.WriteLine(); for (int i = 0; i < removeCount; i++) { Console.Write(addRemoveCollection.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < removeCount; i++) { Console.Write(myList.Remove() + " "); } }
public void Run() { IAddCollection <string> addCollection = new AddCollection <string>(); IAddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>(); IMyList <string> myList = new MyList <string>(); var input = Console.ReadLine(); var addTokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var str in addTokens) { addCollection.Add(str); addRemoveCollection.Add(str); myList.Add(str); } Console.WriteLine(addCollection.ToString()); Console.WriteLine(addRemoveCollection.ToString()); Console.WriteLine(myList.ToString()); int n = int.Parse(Console.ReadLine()); var resultsARC = new List <string>(); var resultsML = new List <string>(); for (int i = 0; i < n; i++) { resultsARC.Add(addRemoveCollection.Remove()); resultsML.Add(myList.Remove()); } Console.WriteLine(string.Join(" ", resultsARC)); Console.WriteLine(string.Join(" ", resultsML)); }
public static void Main() { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] inputParts = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string part in inputParts) { addCollection.Add(part); addRemoveCollection.Add(part); myList.Add(part); } int elementsToRemove = int.Parse(Console.ReadLine()); for (int i = 0; i < elementsToRemove; i++) { addRemoveCollection.Remove(); myList.Remove(); } Console.WriteLine(addCollection); Console.WriteLine(addRemoveCollection); Console.WriteLine(myList); addRemoveCollection.GetRemovedElements(); myList.GetRemovedElements(); }
public void Run() { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] input = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); AddCollections(addCollection, input); AddCollections(addRemoveCollection, input); AddCollections(myList, input); int removeOperationsCount = int.Parse(Console.ReadLine()); for (int i = 0; i < removeOperationsCount; i++) { Console.Write($"{addRemoveCollection.Remove()} "); } Console.WriteLine(); for (int i = 0; i < removeOperationsCount; i++) { Console.Write($"{myList.Remove()} "); } Console.WriteLine(); }
public void Run() { string[] elements = Console.ReadLine().Split(); int n = int.Parse(Console.ReadLine()); foreach (var element in elements) { addCollectionResult.Add(addCollection.Add(element)); addRemoveCollectionResult.Add(addRemoveCollection.Add(element)); myListResult.Add(myList.Add(element)); } for (int i = 0; i < n; i++) { addRemoveCollectionRemoves.Add(addRemoveCollection.Remove()); myListRemoves.Add(myList.Remove()); } foreach (var item in resultInts) { Console.WriteLine(string.Join(" ", item)); } foreach (var item in resultStrings) { Console.WriteLine(string.Join(" ", item)); } }
private void RemoveItems(int removeCount, List <string> removedItemsFromAddRemoveCollection, List <string> removedItemsFromMyList) { for (int i = 0; i < removeCount; i++) { removedItemsFromAddRemoveCollection.Add(addRemoveCollection.Remove()); removedItemsFromMyList.Add(myList.Remove()); } }
private static void RemoveItem(AddRemoveCollection addRemoveCollection, MyList myList, int removesCount) { for (int i = 0; i < removesCount; i++) { addRemoveCollection.Remove(); myList.Remove(); } }
static void Main() { var list = new AddRemoveCollection(); list.Add("PEsho"); list.Add("tt"); list.Add("bb"); Console.WriteLine(list.Remove()); }
static void Main(string[] args) { AddCollection <string> addCollection = new AddCollection <string>(); AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>(); MyList <string> myList = new MyList <string>(); string[] elements = Console.ReadLine().Split(); int removeOperationsCount = int.Parse(Console.ReadLine()); int[,] indexes = new int[3, elements.Length]; for (int col = 0; col < elements.Length; col++) { string element = elements[col]; indexes[0, col] = addCollection.AddElement(element); indexes[1, col] = addRemoveCollection.AddElement(element); indexes[2, col] = myList.AddElement(element); } string[,] stringRemoveElements = new string[2, removeOperationsCount]; for (int col = 0; col < removeOperationsCount; col++) { stringRemoveElements[0, col] = addRemoveCollection.Remove(); stringRemoveElements[1, col] = myList.Remove(); } PrintIndexes(indexes); PrintRemovedElements(stringRemoveElements); //foreach (var element in elements) //{ // Console.Write(addCollection.AddElement(element) + " "); // addRemoveCollection.AddElement(element); //} //Console.WriteLine(); //foreach (var element in elements) //{ // Console.Write(addRemoveCollection.AddElement(element) + " "); //} //Console.WriteLine(); //foreach (var element in elements) //{ // Console.Write(myList.AddElement(element) + " "); //} //Console.WriteLine(); //for (int i = 0; i < removeOperationsCount; i++) //{ // Console.Write(addRemoveCollection.Remove() + " "); //} //Console.WriteLine(); //for (int i = 0; i < removeOperationsCount; i++) //{ // Console.Write(myList.Remove() + " "); //} }
private List <string> RemoveInAddRemoveCollection(int numberRemoveOperations) { List <string> result = new List <string>(); for (int i = 0; i < numberRemoveOperations; i++) { result.Add(addRemoveCollection.Remove()); } return(result); }
private void RemoveFrom(AddRemoveCollection collection, int itemsToRemove) { for (int i = 0; i < itemsToRemove; i++) { sb.Append($"{collection.Remove()}"); if (i < itemsToRemove - 1) { sb.Append(" "); } } sb.AppendLine(); }
static void Main(string[] args) { string[] tokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); int m = int.Parse(Console.ReadLine()); int n = tokens.Length; AddCollection a = new AddCollection(); for (int i = 0; i < n; i++) { Console.Write($"{a.Add(tokens[i])} "); } Console.WriteLine(); AddRemoveCollection b = new AddRemoveCollection(); for (int i = 0; i < n; i++) { Console.Write(b.Add(tokens[i]) + " "); } Console.WriteLine(); MyList c = new MyList(); for (int i = 0; i < n; i++) { Console.Write(c.Add(tokens[i]) + " "); } Console.WriteLine(); for (int i = 0; i < m; i++) { Console.Write(b.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < m; i++) { Console.Write(c.Remove() + " "); } Console.WriteLine(); Console.ReadKey(); }
public static void Main() { string[] collection = Console.ReadLine().Split(' ').ToArray(); int removeCount = int.Parse(Console.ReadLine()); var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); for (int i = 0; i < collection.Length; i++) { var index = addCollection.Add(collection[i]); Console.Write(index + " "); } Console.WriteLine(); for (int i = 0; i < collection.Length; i++) { var index = addRemoveCollection.Add(collection[i]); Console.Write(index + " "); } Console.WriteLine(); for (int i = 0; i < collection.Length; i++) { var index = myList.Add(collection[i]); Console.Write(index + " "); } Console.WriteLine(); for (int i = 0; i < removeCount; i++) { var index = addRemoveCollection.Remove(); Console.Write(index + " "); } Console.WriteLine(); for (int i = 0; i < removeCount; i++) { var index = myList.Remove(); Console.Write(index + " "); } }
public static void Main() { string[] elementsForAdd = Console.ReadLine().Split(); int countOfRemoveOps = int.Parse(Console.ReadLine()); AddRemoveCollection addRemove = new AddRemoveCollection(); AddCollection addCollection = new AddCollection(); MyList myList = new MyList(); foreach (string elementForAdd in elementsForAdd) { int index = addCollection.Add(elementForAdd); Console.Write(index + " "); myList.Add(elementForAdd); } Console.WriteLine(); foreach (string elementForAdd in elementsForAdd) { int index = addRemove.Add(elementForAdd); Console.Write(index + " "); } Console.WriteLine(); foreach (string elementForAdd in elementsForAdd) { int index = myList.Add(elementForAdd); Console.Write(index + " "); } Console.WriteLine(); for (int i = 0; i < countOfRemoveOps; i++) { string element = addRemove.Remove(); Console.Write(element + " "); } Console.WriteLine(); for (int i = 0; i < countOfRemoveOps; i++) { string element = myList.Remove(); Console.Write(element + " "); } }
public static void Main(string[] args) { IAddCollection <string> addCollection = new AddCollection <string>(); IAddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>(); IMyList <string> myList = new MyList <string>(); var elements = Console.ReadLine().Split(); var addCollectionAddIndexes = String.Empty; var addRemoveCollectionAddIndexes = String.Empty; var myListAddIndexes = String.Empty; int index; foreach (var element in elements) { index = addCollection.Add(element); addCollectionAddIndexes += index + " "; index = addRemoveCollection.Add(element); addRemoveCollectionAddIndexes += index + " "; index = myList.Add(element); myListAddIndexes += index + " "; } Console.WriteLine(addCollectionAddIndexes.Trim()); Console.WriteLine(addRemoveCollectionAddIndexes.Trim()); Console.WriteLine(myListAddIndexes.Trim()); var countOfRemoveOperations = int.Parse(Console.ReadLine()); var addRemoveCollectionRemoveElements = String.Empty; var myListAddRemoveElements = String.Empty; var elementToRemove = string.Empty; for (int i = 0; i < countOfRemoveOperations; i++) { elementToRemove = addRemoveCollection.Remove(); addRemoveCollectionRemoveElements += elementToRemove + " "; elementToRemove = myList.Remove(); myListAddRemoveElements += elementToRemove + " "; } Console.WriteLine(addRemoveCollectionRemoveElements.Trim()); Console.WriteLine(myListAddRemoveElements.Trim()); }
public static void Main() { var addCollection = new AddCollection <string>(); var addRemoveCollection = new AddRemoveCollection <string>(); var myList = new MyList <string>(); var addIndicesAddCollection = String.Empty; var addIndicesAddRemoveCollection = String.Empty; var addIndicesMyList = String.Empty; var elements = Console.ReadLine().Split(); int AddIndex; foreach (var element in elements) { AddIndex = addCollection.Add(element); addIndicesAddCollection += $"{AddIndex} "; AddIndex = addRemoveCollection.Add(element); addIndicesAddRemoveCollection += $"{AddIndex} "; AddIndex = myList.Add(element); addIndicesMyList += $"{AddIndex} "; } var amountOfRemoves = int.Parse(Console.ReadLine()); var removedItemFromAddRemoveCollection = String.Empty; var removedItemFromMyList = String.Empty; var removedItem = string.Empty; for (int i = 0; i < amountOfRemoves; i++) { removedItem = addRemoveCollection.Remove(); removedItemFromAddRemoveCollection += $"{removedItem} "; removedItem = myList.Remove(); removedItemFromMyList += $"{removedItem} "; } Console.WriteLine(addIndicesAddCollection.TrimEnd()); Console.WriteLine(addIndicesAddRemoveCollection.TrimEnd()); Console.WriteLine(addIndicesMyList.TrimEnd()); Console.WriteLine(removedItemFromAddRemoveCollection.TrimEnd()); Console.WriteLine(removedItemFromMyList.TrimEnd()); }
private static void RemoveItems(int countRemove, AddRemoveCollection addRemoveCollection, MyList myList) { for (int i = 0; i < countRemove; i++) { Console.Write(addRemoveCollection.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < countRemove; i++) { Console.Write(myList.Remove() + " "); } Console.WriteLine(); }