public static void Main() { var input = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); int remove = int.Parse(Console.ReadLine()); var sb = new StringBuilder(); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); foreach (var item in input) { sb.Append(addCollection.Add(item) + " "); } sb.AppendLine(); foreach (var item in input) { sb.Append(addRemoveCollection.Add(item) + " "); } sb.AppendLine(); foreach (var item in input) { sb.Append(myList.Add(item) + " "); } sb.AppendLine(); sb.Append(addRemoveCollection.Remove(remove)); sb.Append(myList.Remove(remove)); Console.WriteLine(sb); }
public static void Main() { string[] amountOfStrings = Console.ReadLine().Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries); AddCollection <string> addCollection = new AddCollection <string>(); AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>(); MyList <string> myList = new MyList <string>(); for (int i = 0; i < amountOfStrings.Length; i++) { addCollection.Add(amountOfStrings[i]); addRemoveCollection.Add(amountOfStrings[i]); myList.Add(amountOfStrings[i]); } Console.WriteLine(addCollection); Console.WriteLine(addRemoveCollection); Console.WriteLine(myList); int removeElement = int.Parse(Console.ReadLine()); for (int i = 0; i < removeElement; i++) { addRemoveCollection.Remove(); myList.Remove(); } Console.WriteLine(addRemoveCollection.RemoveCollection(removeElement)); Console.WriteLine(myList.RemoveCollection(removeElement)); }
static void Main(string[] args) { 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(); }
static void Main() { var strings = Console.ReadLine().Split(); int numberOfRemoveOperations = int.Parse(Console.ReadLine()); var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var sbAddCollOutput = new StringBuilder(); foreach (var item in strings) { sbAddCollOutput.Append(addCollection.Add(item) + " "); } var sbAddRemCollOutput = new StringBuilder(); foreach (var item in strings) { sbAddRemCollOutput.Append(addRemoveCollection.Add(item) + " "); } var sbMyListOutput = new StringBuilder(); foreach (var item in strings) { sbMyListOutput.Append(myList.Add(item) + " "); } var sbAddRemCollRemovedItems = new StringBuilder(); for (int i = 0; i < numberOfRemoveOperations; i++) { sbAddRemCollRemovedItems.Append(addRemoveCollection.Remove() + " "); } var sbMyListRemovedItems = new StringBuilder(); for (int i = 0; i < numberOfRemoveOperations; i++) { sbMyListRemovedItems.Append(myList.Remove() + " "); } Console.WriteLine(sbAddCollOutput.ToString().TrimEnd()); Console.WriteLine(sbAddRemCollOutput.ToString().TrimEnd()); Console.WriteLine(sbMyListOutput.ToString().TrimEnd()); Console.WriteLine(sbAddRemCollRemovedItems.ToString().TrimEnd()); Console.WriteLine(sbMyListRemovedItems.ToString().TrimEnd()); }
public static void Main() { 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() { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine(string.Join(" ", addCollection.Add(input))); Console.WriteLine(string.Join(" ", addRemoveCollection.Add(input))); Console.WriteLine(string.Join(" ", myList.Add(input))); int countRemove = int.Parse(Console.ReadLine()); Console.WriteLine(string.Join(" ", myList.Remove(countRemove))); Console.WriteLine(string.Join(" ", addRemoveCollection.Remove(countRemove))); }
static void AddInputToLists(AddCollection addColl, AddRemoveCollection addRemColl, MyList myList, string[] input) { var sbAddColl = new StringBuilder(); var sbAddRemColl = new StringBuilder(); var sbMyList = new StringBuilder(); for (int i = 0; i < input.Length; i++) { string token = input[i]; sbAddColl.Append(addColl.Add(token) + " "); sbAddRemColl.Append(addRemColl.Add(token) + " "); sbMyList.Append(myList.Add(token) + " "); } Console.WriteLine(sbAddColl.ToString().Trim()); Console.WriteLine(sbAddRemColl.ToString().Trim()); Console.WriteLine(sbMyList.ToString().Trim()); }
public static void Main() { var addOnlyCollection = new AddOnlyCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var addOperations1 = new List <int>(); var addOperations2 = new List <int>(); var addOperations3 = new List <int>(); string[] itemsToAdd = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in itemsToAdd) { int addIndex1 = addOnlyCollection.Add(item); addOperations1.Add(addIndex1); int addIndex2 = addRemoveCollection.Add(item); addOperations2.Add(addIndex2); int addIndex3 = myList.Add(item); addOperations3.Add(addIndex3); } var removeOperations1 = new List <string>(); var removeOperations2 = new List <string>(); int amoutOfitemsToRemove = int.Parse(Console.ReadLine()); for (int i = 0; i < amoutOfitemsToRemove; i++) { string removedItem1 = addRemoveCollection.Remove(); removeOperations1.Add(removedItem1); string removedItem2 = myList.Remove(); removeOperations2.Add(removedItem2); } Console.WriteLine(string.Join(" ", addOperations1)); Console.WriteLine(string.Join(" ", addOperations2)); Console.WriteLine(string.Join(" ", addOperations3)); Console.WriteLine(string.Join(" ", removeOperations1)); Console.WriteLine(string.Join(" ", removeOperations2)); }
public void Run() { string[] input = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] acOutput = new string[input.Length]; string[] arcOutput = new string[input.Length]; string[] myOutput = new string[input.Length]; for (int i = 0; i < input.Length; i++) { acOutput[i] = addCollection.Add(input[i]).ToString(); arcOutput[i] = addRemoveCollection.Add(input[i]).ToString(); myOutput[i] = myList.Add(input[i]).ToString(); } Console.WriteLine(String.Join(" ", acOutput)); Console.WriteLine(String.Join(" ", arcOutput)); Console.WriteLine(String.Join(" ", myOutput)); int countElementsToRemove = int.Parse(Console.ReadLine()); for (int i = 0; i < countElementsToRemove; i++) { Console.Write(addRemoveCollection.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < countElementsToRemove; i++) { Console.Write(myList.Remove() + " "); } Console.WriteLine(); }
public static void Main() { string[] words = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int removes = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myListCollection = new MyList(); foreach (var word in words) { Console.Write($"{addCollection.Add(word)} "); } Console.WriteLine(); foreach (var word in words) { Console.Write($"{addRemoveCollection.Add(word)} "); } Console.WriteLine(); foreach (var word in words) { Console.Write($"{myListCollection.Add(word)} "); } Console.WriteLine(); for (int i = 0; i < removes; i++) { Console.Write($"{addRemoveCollection.Remove()} "); } Console.WriteLine(); for (int i = 0; i < removes; i++) { Console.Write($"{myListCollection.Remove()} "); } Console.WriteLine(); }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(); IAddable addList = new AddCollection(); IRemovable addRemoveList = new AddRemoveCollection(); IUsable myList = new MyList(); foreach (var str in input) { Console.Write(addList.Add(str) + " "); } Console.WriteLine(); foreach (var str in input) { Console.Write(addRemoveList.Add(str) + " "); } Console.WriteLine(); foreach (var str in input) { Console.Write(myList.Add(str) + " "); } Console.WriteLine(); int removesCount = int.Parse(Console.ReadLine()); for (int j = 0; j < removesCount; j++) { Console.Write(addRemoveList.Remove() + " "); } Console.WriteLine(); for (int j = 0; j < removesCount; j++) { Console.Write(myList.Remove() + " "); } Console.WriteLine(); }
public static void Main() { var addCollevtion = new AddCollection(); var addRamoveCollection = new AddRemoveCollection(); var myList = new MyList(); var input = Console.ReadLine() .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var addCollAdds = new byte[input.Length]; var addRemoveCollAdds = new byte[input.Length]; var myListAdds = new byte[input.Length]; for (int i = 0; i < input.Length; i++) { addCollAdds[i] = addCollevtion.Add(input[i]); addRemoveCollAdds[i] = addRamoveCollection.Add(input[i]); myListAdds[i] = myList.Add(input[i]); } var numberOfRemoves = int.Parse(Console.ReadLine()); var addRemoveCollRemoves = new string[numberOfRemoves]; var myListRemoves = new string[numberOfRemoves]; for (int i = 0; i < numberOfRemoves; i++) { addRemoveCollRemoves[i] = addRamoveCollection.Remove(); myListRemoves[i] = myList.Remove(); } Console.WriteLine(string.Join(" ", addCollAdds)); Console.WriteLine(string.Join(" ", addRemoveCollAdds)); Console.WriteLine(string.Join(" ", myListAdds)); Console.WriteLine(string.Join(" ", addRemoveCollRemoves)); Console.WriteLine(string.Join(" ", myListRemoves)); }