private static void Addding(AddCollection addCollection, int n, string[] elements) { for (int i = 0; i < n; i++) { Console.Write(addCollection.AddElement(elements[i]) + " "); } }
static void Main() { AddCollection addColection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] input = Console.ReadLine().Split().ToArray(); for (int i = 0; i < input.Length; i++) { string element = input[i]; addColection.Add(element); addRemoveCollection.Add(element); myList.Add(element); } int count = int.Parse(Console.ReadLine()); for (int i = 0; i < count; i++) { addRemoveCollection.Remove(); myList.Remove(); } Console.WriteLine(string.Join(" ", addColection.AddResult)); Console.WriteLine(string.Join(" ", addRemoveCollection.AddResult)); Console.WriteLine(string.Join(" ", myList.AddResult)); Console.WriteLine(string.Join(" ", addRemoveCollection.RemoveResult)); Console.WriteLine(string.Join(" ", myList.RemoveResult)); }
static void Main() { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var line1 = new List <int>(); var line2 = new List <int>(); var line3 = new List <int>(); var input = Console.ReadLine().Split(); foreach (var item in input) { line1.Add(addCollection.Add(item)); line2.Add(addRemoveCollection.Add(item)); line3.Add(myList.Add(item)); } var removeCount = int.Parse(Console.ReadLine()); var line4 = new List <string>(); var line5 = new List <string>(); for (int i = 0; i < removeCount; i++) { line4.Add(addRemoveCollection.Remove()); line5.Add(myList.Remove()); } Console.WriteLine(string.Join(" ", line1)); Console.WriteLine(string.Join(" ", line2)); Console.WriteLine(string.Join(" ", line3)); Console.WriteLine(string.Join(" ", line4)); Console.WriteLine(string.Join(" ", line5)); }
static void Main(string[] args) { string[] inputCollection = Console.ReadLine() .Split(new[] { ' ' }); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); StringBuilder firstLine = new StringBuilder(); StringBuilder secondLine = new StringBuilder(); StringBuilder thirdLine = new StringBuilder(); StringBuilder fourthLine = new StringBuilder(); StringBuilder fifthLine = new StringBuilder(); foreach (var currentIntem in inputCollection) { firstLine.Append(addCollection.Add(currentIntem) + " "); secondLine.Append(addRemoveCollection.Add(currentIntem) + " "); thirdLine.Append(myList.Add(currentIntem) + " "); } var repeat = int.Parse(Console.ReadLine()); for (int i = 0; i < repeat; i++) { fourthLine.Append(addRemoveCollection.Remove() + " "); fifthLine.Append(myList.Remove() + " "); } Console.WriteLine(firstLine); Console.WriteLine(secondLine); Console.WriteLine(thirdLine); Console.WriteLine(fourthLine); Console.WriteLine(fifthLine); }
static void Main(string[] args) { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); List <int> first = new List <int>(); List <int> second = new List <int>(); List <int> third = new List <int>(); string[] items = Console.ReadLine().Split(); foreach (var item in items) { first.Add(addCollection.Add(item)); second.Add(addRemoveCollection.Add(item)); third.Add(myList.Add(item)); } int amountOfRemoveOperations = int.Parse(Console.ReadLine()); List <string> addRemoveColRemovedEls = new List <string>(); List <string> myListRemovedEls = new List <string>(); for (int i = 0; i < amountOfRemoveOperations; i++) { addRemoveColRemovedEls.Add(addRemoveCollection.Remove()); myListRemovedEls.Add(myList.Remove()); } Console.WriteLine(string.Join(" ", first)); Console.WriteLine(string.Join(" ", second)); Console.WriteLine(string.Join(" ", third)); Console.WriteLine(string.Join(" ", addRemoveColRemovedEls)); Console.WriteLine(string.Join(" ", myListRemovedEls)); }
static void Main(string[] args) { AddCollection collection = new AddCollection(); Engine engine = new Engine(); engine.Run(); }
static void Main(string[] args) { AddCollection test = new AddCollection(); AddRemoveCollection test2 = new AddRemoveCollection(); MyList test3 = new MyList(); var inpit = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < inpit.Length; i++) { test.Add(inpit[i]); test3.Add(inpit[i]); test2.Add(inpit[i]); } test.Print(); test2.Print(); test3.Print(); for (int i = 0; i < n; i++) { test2.Remove(); test3.Remove(); } test2.PrintRemoved(); test3.PrintRemoved(); }
public static void Main() { var addCollection = new AddCollection(); var addRemoveCollectiont = new AddRemoveCollection(); var myList = new MyList(); var itemsToAdd = Console.ReadLine().Split(); var removeOperationsCount = int.Parse(Console.ReadLine()); var addCollIndexes = new StringBuilder(); var addRemoveIndexes = new StringBuilder(); var myListCollAddIndexes = new StringBuilder(); foreach (var item in itemsToAdd) { addCollIndexes.Append(addCollection.Add(item)).Append(" "); addRemoveIndexes.Append(addRemoveCollectiont.Add(item)).Append(" "); myListCollAddIndexes.Append(myList.Add(item)).Append(" "); } var removeElementFromAddRemoveColl = new StringBuilder(); var removeElementFormMyList = new StringBuilder(); for (int i = 0; i < removeOperationsCount; i++) { removeElementFromAddRemoveColl.Append(addRemoveCollectiont.Remove()).Append(" "); removeElementFormMyList.Append(myList.Remove()).Append(" "); } Console.WriteLine(addCollIndexes.ToString().Trim()); Console.WriteLine(addRemoveIndexes.ToString().Trim()); Console.WriteLine(myListCollAddIndexes.ToString().Trim()); Console.WriteLine(removeElementFromAddRemoveColl.ToString().Trim()); Console.WriteLine(removeElementFormMyList.ToString().Trim()); }
static void Main(string[] args) { string[] elements = Console.ReadLine().Split(); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); Addding(addCollection, elements.Length, elements); Console.WriteLine(); Addding(addRemoveCollection, elements.Length, elements); Console.WriteLine(); Addding(myList, elements.Length, elements); Console.WriteLine(); int n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { Console.Write(addRemoveCollection.RemoveElement() + " "); } Console.WriteLine(); for (int i = 0; i < n; i++) { Console.Write(myList.RemoveElement() + " "); } }
public static void Main() { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] items = Console.ReadLine().Split(); int removeOperations = int.Parse(Console.ReadLine()); foreach (var item in items) { Console.Write(addCollection.Add(item) + " "); } Console.WriteLine(); foreach (var item in items) { Console.Write(addRemoveCollection.Add(item) + " "); } Console.WriteLine(); foreach (var item in items) { 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() + " "); } }
static void Main(string[] args) { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] input = Console.ReadLine().Split(); int countOfRemoves = int.Parse(Console.ReadLine()); List <int> addData = new List <int>(); List <int> removeData = new List <int>(); List <int> totData = new List <int>(); List <string> removeResult = new List <string>(); List <string> totResult = new List <string>(); foreach (string word in input) { addData.Add(addCollection.Add(word)); removeData.Add(addRemoveCollection.Add(word)); totData.Add(myList.Add(word)); } for (int i = 0; i < countOfRemoves; i++) { removeResult.Add(addRemoveCollection.Remove()); totResult.Add(myList.Remove()); } Console.WriteLine(string.Join(" ", addData)); Console.WriteLine(string.Join(" ", removeData)); Console.WriteLine(string.Join(" ", totData)); Console.WriteLine(string.Join(" ", removeResult)); Console.WriteLine(string.Join(" ", totResult)); }
static void Main(string[] args) { List <string> myList = Console.ReadLine().Split().ToList(); int countOfRemoves = int.Parse(Console.ReadLine()); AddCollection collection = new AddCollection(); collection.CollectedData = myList; }
static void Main(string[] args) { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); Engine engine = new Engine(addCollection, addRemoveCollection, myList); engine.Run(); }
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); }
public static void Main() { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var engine = new Engine( addCollection, addRemoveCollection, myList); engine.Run(); }
static void Main(string[] args) { string[] addElements = Console.ReadLine().Split(); int removingElementsCount = int.Parse(Console.ReadLine()); AddCollection <string> addCollection = new AddCollection <string>(); AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>(); MyList <string> myList = new MyList <string>(); List <int> addCollectionIndices = new List <int>(); List <int> addRemoveCollectionIndices = new List <int>(); List <int> myListIndices = new List <int>(); List <string> addRemoveCollectionRemoved = new List <string>(); List <string> myListRemoved = new List <string>(); int indexOfAddCollection; int indexOfAddRemoveCollection; int indexOfMyList; foreach (string element in addElements) { indexOfAddCollection = addCollection.Add(element); addCollectionIndices.Add(indexOfAddCollection); indexOfAddRemoveCollection = addRemoveCollection.Add(element); addRemoveCollectionIndices.Add(indexOfAddRemoveCollection); indexOfMyList = myList.Add(element); myListIndices.Add(indexOfMyList); } string removedElementFromAddRemoveCollection; string removedElementFromMyList; for (int curr = 0; curr < removingElementsCount; curr++) { removedElementFromAddRemoveCollection = addRemoveCollection.Remove(); addRemoveCollectionRemoved.Add(removedElementFromAddRemoveCollection); removedElementFromMyList = myList.Remove(); myListRemoved.Add(removedElementFromMyList); } Console.WriteLine(string.Join(" ", addCollectionIndices)); Console.WriteLine(string.Join(" ", addRemoveCollectionIndices)); Console.WriteLine(string.Join(" ", myListIndices)); Console.WriteLine(string.Join(" ", addRemoveCollectionRemoved)); Console.WriteLine(string.Join(" ", myListRemoved)); }
public static void Main(string[] args) { var input = Console.ReadLine().Split(); var n = int.Parse(Console.ReadLine()); // number of remove operations var myCollection = new MyCollection(input); var myAddCollection = new AddCollection(input); var myAddRemoveCollection = new AddRemoveCollection(input); var myList = new MyList(input); Console.WriteLine(string.Join(" ", myAddCollection.Add(input.ToList()))); Console.WriteLine(string.Join(" ", myAddRemoveCollection.Add(input.ToList()))); Console.WriteLine(string.Join(" ", myList.Add(input.ToList()))); Console.WriteLine(string.Join(" ", myAddRemoveCollection.Remove(input, n))); Console.WriteLine(string.Join(" ", myList.Remove(input, n))); }
static void Main(string[] args) { AddCollection add = new AddCollection(); AddRemoveCollection addRemove = new AddRemoveCollection(); MyList myList = new MyList(); string[] input = Console.ReadLine().Split(); int indexRemove = int.Parse(Console.ReadLine()); Add(add, addRemove, myList, input); Console.WriteLine(); Remove(addRemove, myList, indexRemove); }
static void Main(string[] args) { string[] elements = Console.ReadLine().Split(); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string addIndicesAddCollection = String.Empty; string addIndicesAddRemoveCollection = String.Empty; string addIndicesMyList = String.Empty; int indexOfAdding = 0; foreach (var element in elements) { indexOfAdding = addCollection.Add(element); addIndicesAddCollection += $"{indexOfAdding} "; indexOfAdding = addRemoveCollection.Add(element); addIndicesAddRemoveCollection += $"{indexOfAdding} "; indexOfAdding = myList.Add(element); addIndicesMyList += $"{indexOfAdding} "; } int amountOfRemoves = int.Parse(Console.ReadLine()); string removedItemFromAddRemoveCollection = String.Empty; string removedItemFromMyList = String.Empty; string 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()); }
static void Main(string[] args) { string[] data = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries) .ToArray(); int number = int.Parse(Console.ReadLine()); Collect addCollection = new AddCollection(); AddRemoveCollection addRemove = new AddRemoveCollection(); MyList list = new MyList(); ForEachData(data, addCollection); ForEachData(data, addRemove); ForEachData(data, list); Remove(data, number, addRemove); Remove(data, number, list); }
static void Main(string[] args) { var cmdArgs = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray(); var removeIterations = int.Parse(Console.ReadLine()); var addCollection = new AddCollection(); var result = new List <int>(); foreach (var item in cmdArgs) { result.Add(addCollection.Add(item)); } Console.WriteLine(String.Join(" ", result)); var addRemoveCollection = new AddRemoveCollection(); result.Clear(); foreach (var item in cmdArgs) { result.Add(addRemoveCollection.Add(item)); } Console.WriteLine(String.Join(" ", result)); var myList = new MyList(); result.Clear(); foreach (var item in cmdArgs) { result.Add(myList.Add(item)); } Console.WriteLine(String.Join(" ", result)); var removeResult = new List <string>(); for (int i = 0; i < removeIterations; i++) { removeResult.Add(addRemoveCollection.Remove()); } Console.WriteLine(String.Join(" ", removeResult)); removeResult.Clear(); for (int i = 0; i < removeIterations; i++) { removeResult.Add(myList.Remove()); } Console.WriteLine(String.Join(" ", removeResult)); }
public void Run() { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemove = new AddRemoveCollection(); MyList list = new MyList(); var input = Console.ReadLine().Split(); AddInCollections(addCollection, input); AddInCollections(addRemove, input); AddInCollections(list, input); var removeCount = int.Parse(Console.ReadLine()); RemoveFromCollections(addRemove, removeCount); RemoveFromCollections(list, removeCount); }
public static void Main(string[] args) { string[] input = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); foreach (var element in input) { addCollection.AddElement(element); } Console.WriteLine(); foreach (var element in input) { addRemoveCollection.AddElement(element); } Console.WriteLine(); foreach (var element in input) { myList.AddElement(element); } Console.WriteLine(); int countToRemove = int.Parse(Console.ReadLine()); for (int i = 0; i < countToRemove; i++) { addRemoveCollection.RemoveElement(); } Console.WriteLine(); for (int i = 0; i < countToRemove; i++) { myList.RemoveElement(); } Console.WriteLine(); }
public static void Main() { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myListCollection = new MyList(); string[] elements = Console.ReadLine().Split(); AddElements(addCollection, elements); AddElements(addRemoveCollection, elements); AddElements(myListCollection, elements); int numberOfElementsToRemove = int.Parse(Console.ReadLine()); RemoveElements(addRemoveCollection, numberOfElementsToRemove); RemoveElements(myListCollection, numberOfElementsToRemove); }
static void Main(string[] args) { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var inputs = Console.ReadLine().Split(); AddAllItems(addCollection, inputs); AddAllItems(addRemoveCollection, inputs); AddAllItems(myList, inputs); var toRemove = int.Parse(Console.ReadLine()); RemoveItems(addRemoveCollection, toRemove); RemoveItems(myList, toRemove); }
static void Main(string[] args) { string[] input = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray(); int count = int.Parse(Console.ReadLine()); var addCollection = new AddCollection <string>(); var addRemoveCollection = new AddRemoveCollection <string>(); var myList = new MyList <string>(); AddItems <string>(input, addCollection); AddItems <string>(input, addRemoveCollection); AddItems <string>(input, myList); RemoveItems <string>(input, addRemoveCollection, count); RemoveItems <string>(input, myList, count); }
public static void Main() { AddCollection add = new AddCollection(); AddRemoveCollection addRemove = new AddRemoveCollection(); MyList myList = new MyList(); string[] input = Console.ReadLine().Split(); AddToCollection(input, add); AddToCollection(input, addRemove); AddToCollection(input, myList); int numberOfRemove = int.Parse(Console.ReadLine()); Remove(numberOfRemove, addRemove); Remove(numberOfRemove, myList); }
static void Main(string[] args) { string[] inputItems = Console.ReadLine().Split(); var addCollection = new AddCollection(); var removeCollection = new AddRemoveCollection(); var myList = new MyList(); StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); StringBuilder sb3 = new StringBuilder(); foreach (var item in inputItems) { //addCollection.AddCollections(item); sb1.Append(addCollection.AddCollections(item)).Append(" "); //removeCollection.AddCollections(item); sb2.Append(removeCollection.AddCollections(item)).Append(" "); //myList.AddCollections(item); sb3.Append(myList.AddCollections(item)).Append(" "); } int n = int.Parse(Console.ReadLine()); StringBuilder sb4 = new StringBuilder(); StringBuilder sb5 = new StringBuilder(); while (n > 0) { //removeCollection.Remove(); sb4.Append(removeCollection.Remove()).Append(" "); //myList.Remove(); sb5.Append(myList.Remove()).Append(" "); n--; } Console.WriteLine(sb1.ToString().TrimEnd()); Console.WriteLine(sb2.ToString().TrimEnd()); Console.WriteLine(sb3.ToString().TrimEnd()); Console.WriteLine(sb4.ToString().TrimEnd()); Console.WriteLine(sb5.ToString().TrimEnd()); }
static void Main(string[] args) { List <IAddCollection> allCollections = new List <IAddCollection>(); List <IAddRemoveCollection> allRemovableCollections = new List <IAddRemoveCollection>(); AddCollection addCollection = new AddCollection(); allCollections.Add(addCollection); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); allCollections.Add(addRemoveCollection); allRemovableCollections.Add(addRemoveCollection); MyList myList = new MyList(); allCollections.Add(myList); allRemovableCollections.Add(myList); string[] words = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); foreach (IAddCollection collection in allCollections) { foreach (string word in words) { Console.Write($"{collection.Add(word)} "); } Console.WriteLine(); } int n = int.Parse(Console.ReadLine()); foreach (IAddRemoveCollection collection in allRemovableCollections) { for (int i = 0; i < n; i++) { Console.Write($"{collection.Remove()} "); } Console.WriteLine(); } }
public static void Main(string[] args) { var text = Console.ReadLine().Split(); var itemsToDelete = int.Parse(Console.ReadLine()); var sb = new StringBuilder(); var addCollection = new AddCollection(); for (int i = 0; i < text.Length; i++) { sb.Append($"{addCollection.Add(text[i])} "); } sb.AppendLine(); var addRemoveCollection = new AddRemoveCollection(); for (int i = 0; i < text.Length; i++) { sb.Append($"{addRemoveCollection.Add(text[i])} "); } sb.AppendLine(); var myCollection = new MyList(); for (int i = 0; i < text.Length; i++) { sb.Append($"{myCollection.Add(text[i])} "); } sb.AppendLine(); for (int i = 0; i < itemsToDelete; i++) { sb.Append($"{addRemoveCollection.Remove()} "); } sb.AppendLine(); for (int i = 0; i < itemsToDelete; i++) { sb.Append($"{myCollection.Remove()} "); } Console.WriteLine(sb.ToString()); }