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)); }
public Engine() { addCollection = new AddCollection(); addRemoveCollection = new AddRemoveCollection(); myList = new MyList(); sb = new StringBuilder(); }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int countOfRemoves = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); foreach (var item in input) { addCollection.AddItem(item); addRemoveCollection.AddItem(item); myList.AddItem(item); } for (int i = 0; i < countOfRemoves; i++) { addRemoveCollection.RemoveItem(); myList.RemoveItem(); } Console.WriteLine(string.Join(" ", addCollection.CollectionAdds)); Console.WriteLine(string.Join(" ", addRemoveCollection.CollectionAdds)); Console.WriteLine(string.Join(" ", myList.CollectionAdds)); Console.WriteLine(string.Join(" ", addRemoveCollection.CollectionRemovedItems)); Console.WriteLine(string.Join(" ", myList.CollectionRemovedItems)); }
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)); }
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) { 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)); }
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); }
static void Main() { var collection = Console.ReadLine().Split(); var removesCount = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); var sb1 = new StringBuilder(); var sb2 = new StringBuilder(); var sb3 = new StringBuilder(); for (int index = 0; index < collection.Length; index++) { sb1.Append(addCollection.AddToEnd(collection[index])).Append(" "); sb2.Append(addRemoveCollection.AddToStart(collection[index])).Append(" "); sb3.Append(myList.AddToStart(collection[index])).Append(" "); } Console.WriteLine(sb1.ToString().Trim()); Console.WriteLine(sb2.ToString().Trim()); Console.WriteLine(sb3.ToString().Trim()); sb1.Clear(); sb2.Clear(); for (int index = 0; index < removesCount; index++) { sb1.Append(addRemoveCollection.RemoveFromEnd()).Append(" "); sb2.Append(myList.RemoveFromStart()).Append(" "); } Console.WriteLine(sb1.ToString().Trim()); Console.WriteLine(sb2.ToString().Trim()); }
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 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 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 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 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() { 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()); }
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)); }
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(); }
private static void RemoveItem(AddRemoveCollection addRemoveCollection, MyList myList, int removesCount) { for (int i = 0; i < removesCount; i++) { addRemoveCollection.Remove(); myList.Remove(); } }
private static void Print(AddCollection addCollection, AddRemoveCollection addRemoveCollection, MyList myList) { Console.WriteLine(string.Join(" ", addCollection.AddOperations)); Console.WriteLine(string.Join(" ", addRemoveCollection.AddOperations)); Console.WriteLine(string.Join(" ", myList.AddOperations)); Console.WriteLine(string.Join(" ", addRemoveCollection.RemoveOperations)); Console.WriteLine(string.Join(" ", myList.RemoveOperations)); }
static void Main(string[] args) { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); AddElements(addCollection, addRemoveCollection, myList); RemoveElements(addRemoveCollection, myList); }
private static void AddItem(AddCollection addCollection, AddRemoveCollection addRemoveCollection, MyList myList, List <string> elements) { foreach (var item in elements) { addCollection.Add(item); addRemoveCollection.Add(item); myList.Add(item); } }
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() + " "); //} }
public static void Main() { var input = Console.ReadLine().Split(); var countRemove = int.Parse(Console.ReadLine()); var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); ProcessAdd(input, addCollection, addRemoveCollection, myList); ProcessRemove(countRemove, addRemoveCollection, myList); }
static void Main(string[] args) { var inputLines = Console.ReadLine().Split(' '); var countRemove = int.Parse(Console.ReadLine()); var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); AddItems(inputLines, addCollection, addRemoveCollection, myList); RemoveItems(countRemove, addRemoveCollection, myList); }
public static void Main() { var input = Console.ReadLine().Split().ToList(); var removeOperation = int.Parse(Console.ReadLine()); var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); for (int i = 0; i < removeOperation; i++) { } }
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(); }
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(); }
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 + " "); } }