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) { 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() { 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(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 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()); }
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() + " "); } }
private static void Remove(string[] data, int number, AddRemoveCollection collection) { for (int i = 1; i <= number; i++) { Console.Write($"{collection.Remove()} "); } Console.WriteLine(); }
private static void Remove(AddRemoveCollection addRemove, MyList myList, int indexRemove) { for (int i = 0; i < indexRemove; i++) { Console.Write(addRemove.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < indexRemove; i++) { Console.Write(myList.Remove() + " "); } }
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)); }
static void Main(string[] args) { string[] arr = Console.ReadLine().Split(); int n = int.Parse(Console.ReadLine()); AddCollections collection = new AddCollections(); AddRemoveCollection addRemove = new AddRemoveCollection(); MyLists myList = new MyLists(); collection.Add(arr); addRemove.Add(arr); myList.Add(arr); addRemove.Remove(n); myList.Remove(n); }
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) { 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[] 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) { 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 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()); }
static void Main(string[] args) { AddCollection addcollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] items = Console.ReadLine() .Split(); 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(); int removeCount = int.Parse(Console.ReadLine()); for (int i = 0; i < removeCount; i++) { Console.Write($"{addRemoveCollection.Remove()} "); } Console.WriteLine(); for (int i = 0; i < removeCount; i++) { Console.Write($"{myList.Remove()} "); } Console.WriteLine(); }
static void Main(string[] args) { AddCollection ac = new AddCollection(); AddRemoveCollection arc = new AddRemoveCollection(); MyList ml = new MyList(); var input = Console.ReadLine().Split(); foreach (var item in input) { Console.Write($"{ac.Add(item)} "); } Console.WriteLine(); foreach (var item in input) { Console.Write($"{arc.Add(item)} "); } Console.WriteLine(); foreach (var item in input) { Console.Write($"{ml.Add(item)} "); } Console.WriteLine(); int count = int.Parse(Console.ReadLine()); for (int i = 0; i < count; i++) { Console.Write($"{arc.Remove()} "); } Console.WriteLine(); for (int i = 0; i < count; i++) { Console.Write($"{ml.Remove()} "); } Console.WriteLine(); }
public static void Main() { string[] input = Console.ReadLine().Split(' '); int n = int.Parse(Console.ReadLine()); IAddCollection addCollection = new AddCollection(); IAddRemoveCollection addRemoveCollection = new AddRemoveCollection(); IMyList myList = new MyList(); var sb = new StringBuilder(); var firstLine = new StringBuilder(); var secondLine = new StringBuilder(); var thirdLine = new StringBuilder(); foreach (var item in input) { firstLine.Append(addCollection.Add(item) + " "); secondLine.Append(addRemoveCollection.Add(item) + " "); thirdLine.Append(myList.Add(item) + " "); } sb.AppendLine(firstLine.ToString().TrimEnd()); sb.AppendLine(secondLine.ToString().TrimEnd()); sb.AppendLine(thirdLine.ToString().TrimEnd()); firstLine.Clear(); secondLine.Clear(); thirdLine.Clear(); for (int i = 0; i < n; i++) { firstLine.Append(addRemoveCollection.Remove() + " "); secondLine.Append(myList.Remove() + " "); } sb.AppendLine(firstLine.ToString().TrimEnd()); sb.Append(secondLine.ToString().TrimEnd()); Console.WriteLine(sb); }
static void Main(string[] args) { var col1 = new AddColection(); var col2 = new AddRemoveCollection(); var col3 = new MyList(); string[] strs = Console.ReadLine().Split(); int removeOps = int.Parse(Console.ReadLine()); for (int i = 0; i < strs.Length; i++) { Console.Write(col1.Add(strs[i]).ToString() + ' '); } Console.WriteLine(); for (int i = 0; i < strs.Length; i++) { Console.Write(col2.Add(strs[i]).ToString() + ' '); } Console.WriteLine(); for (int i = 0; i < strs.Length; i++) { Console.Write(col3.Add(strs[i]).ToString() + ' '); } Console.WriteLine(); for (int i = 0; i < removeOps; i++) { Console.Write(col2.Remove() + ' '); } Console.WriteLine(); for (int i = 0; i < removeOps; i++) { Console.Write(col3.Remove() + ' '); } Console.WriteLine(); }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int removes = int.Parse(Console.ReadLine()); MyList myList = new MyList(); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); 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 < removes; i++) { Console.Write(addRemoveCollection.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < removes; i++) { Console.Write(myList.Remove() + " "); } }
public static void Main() { AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); string[] strings = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); List <int> addCollectionAddOperations = new List <int>(); List <int> addRemoveCollectionAddOperations = new List <int>(); List <int> myListAddOperations = new List <int>(); List <string> addRemoveCollectionRemoveOperations = new List <string>(); List <string> myListRemoveOperations = new List <string>(); foreach (string currentString in strings) { addCollectionAddOperations.Add(addCollection.Add(currentString)); addRemoveCollectionAddOperations.Add(addRemoveCollection.Add(currentString)); myListAddOperations.Add(myList.Add(currentString)); } int removeOperations = int.Parse(Console.ReadLine()); for (int i = 0; i < removeOperations; i++) { addRemoveCollectionRemoveOperations.Add(addRemoveCollection.Remove()); myListRemoveOperations.Add(myList.Remove()); } Console.WriteLine(string.Join(" ", addCollectionAddOperations)); Console.WriteLine(string.Join(" ", addRemoveCollectionAddOperations)); Console.WriteLine(string.Join(" ", myListAddOperations)); Console.WriteLine(string.Join(" ", addRemoveCollectionRemoveOperations)); Console.WriteLine(string.Join(" ", myListRemoveOperations)); }
static void Main(string[] args) { string[] firstLine = Console.ReadLine().Split(); int n = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); Dictionary <IAdding, List <int> > addIndexes = new Dictionary <IAdding, List <int> >(); addIndexes.Add(addCollection, new List <int>()); addIndexes.Add(addRemoveCollection, new List <int>()); addIndexes.Add(myList, new List <int>()); Dictionary <IRemoving, List <string> > removedStrings = new Dictionary <IRemoving, List <string> >(); removedStrings.Add(addRemoveCollection, new List <string>()); removedStrings.Add(myList, new List <string>()); for (int i = 0; i < firstLine.Length; i++) { addIndexes[addCollection].Add(addCollection.Add(firstLine[i])); addIndexes[addRemoveCollection].Add(addRemoveCollection.Add(firstLine[i])); addIndexes[myList].Add(myList.Add(firstLine[i])); } for (int i = 0; i < n; i++) { removedStrings[addRemoveCollection].Add(addRemoveCollection.Remove()); removedStrings[myList].Add(myList.Remove()); } foreach (var kvp in addIndexes) { Console.WriteLine(string.Join(" ", kvp.Value)); } foreach (var kvp in removedStrings) { Console.WriteLine(string.Join(" ", kvp.Value)); } }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(); int number = int.Parse(Console.ReadLine()); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); Console.WriteLine(string.Join(" ", addCollection.Add(input))); Console.WriteLine(string.Join(" ", addRemoveCollection.Add(input))); Console.WriteLine(string.Join(" ", myList.Add(input))); for (int i = 0; i < number; i++) { Console.Write(addRemoveCollection.Remove() + " "); } Console.WriteLine(); for (int i = 0; i < number; i++) { Console.Write(myList.Remove() + " "); } }
static void Main(string[] args) { string[] insertMe = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); int removeTimes = int.Parse(Console.ReadLine()); List <int> addCollectionCount = new List <int>(); List <int> addRemoveCollectionCount = new List <int>(); List <int> myListCount = new List <int>(); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); for (int i = 0; i < insertMe.Length; i++) { addCollectionCount.Add(addCollection.Add(insertMe[i])); addRemoveCollectionCount.Add(addRemoveCollection.Add(insertMe[i])); myListCount.Add(myList.Add(insertMe[i])); } List <string> removeCount = new List <string>(); List <string> myListRemoveCount = new List <string>(); for (int i = 0; i < removeTimes; i++) { removeCount.Add(addRemoveCollection.Remove()); myListRemoveCount.Add(myList.Remove()); } Console.WriteLine(string.Join(' ', addCollectionCount)); Console.WriteLine(string.Join(' ', addRemoveCollectionCount)); Console.WriteLine(string.Join(' ', myListCount)); Console.WriteLine(string.Join(' ', removeCount)); Console.WriteLine(string.Join(' ', myListRemoveCount)); }
public static void Main() { string[] elements = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); List <int> addCollResults = new List <int>(); List <int> addRemCollResults = new List <int>(); List <int> myListCollResults = new List <int>(); foreach (var element in elements) { addCollResults.Add(addCollection.Add(element)); addRemCollResults.Add(addRemoveCollection.Add(element)); myListCollResults.Add(myList.Add(element)); } Console.WriteLine(string.Join(' ', addCollResults)); Console.WriteLine(string.Join(' ', addRemCollResults)); Console.WriteLine(string.Join(' ', myListCollResults)); int removeCount = int.Parse(Console.ReadLine()); List <string> addRemoveResults = new List <string>(); List <string> myListResults = new List <string>(); for (int i = 0; i < removeCount; i++) { addRemoveResults.Add(addRemoveCollection.Remove()); myListResults.Add(myList.Remove()); } Console.WriteLine(string.Join(' ', addRemoveResults)); Console.WriteLine(string.Join(' ', myListResults)); }
public static void Main() { IAddCollection addCollection = new AddCollection(); IAddRemoveCollection addRemoveCollection = new AddRemoveCollection(); IMyList myList = new MyList(); string[] input = Console.ReadLine().Split(); string addCollectionOutput = string.Empty; string addRemoveCollectionOutput = string.Empty; string myListOutput = string.Empty; foreach (string item in input) { addCollectionOutput += $"{addCollection.Add(item)} "; addRemoveCollectionOutput += $"{addRemoveCollection.Add(item)} "; myListOutput += $"{myList.Add(item)} "; } Console.WriteLine(addCollectionOutput.TrimEnd()); Console.WriteLine(addRemoveCollectionOutput.TrimEnd()); Console.WriteLine(myListOutput.TrimEnd()); int removeOpsCount = int.Parse(Console.ReadLine()); addRemoveCollectionOutput = string.Empty; myListOutput = string.Empty; for (int i = 0; i < removeOpsCount; i++) { addRemoveCollectionOutput += $"{addRemoveCollection.Remove()} "; myListOutput += $"{myList.Remove()} "; } Console.WriteLine(addRemoveCollectionOutput.TrimEnd()); Console.WriteLine(myListOutput.TrimEnd()); }
public static void Main() { var addCollection = new AddCollection <string>(); var addRemoveCollection = new AddRemoveCollection <string>(); var myList = new MyList <string>(); string[] strs = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); var acOps = new List <int>(); var arcOps = new List <int>(); var mlOps = new List <int>(); foreach (var str in strs) { acOps.Add(addCollection.Add(str)); arcOps.Add(addRemoveCollection.Add(str)); mlOps.Add(myList.Add(str)); } Console.WriteLine(Concatenate(acOps)); Console.WriteLine(Concatenate(arcOps)); Console.WriteLine(Concatenate(mlOps)); int removeOperationsCount = int.Parse(Console.ReadLine()); string[] arcRemoved = new string[removeOperationsCount]; string[] mlRemoved = new string[removeOperationsCount]; for (int i = 0; i < removeOperationsCount; i++) { arcRemoved[i] = addRemoveCollection.Remove(); mlRemoved[i] = myList.Remove(); } Console.WriteLine(Concatenate(arcRemoved)); Console.WriteLine(Concatenate(mlRemoved)); }
static void Main(string[] args) { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var inputs = Console.ReadLine().Split(' '); var outputs = new StringBuilder[5]; for (int i = 0; i < 5; ++i) { outputs[i] = new StringBuilder(); } foreach (var input in inputs) { outputs[0].Append(addCollection.Add(input) + " "); outputs[1].Append(addRemoveCollection.Add(input) + " "); outputs[2].Append(myList.Add(input) + " "); } int removeCount = int.Parse(Console.ReadLine()); for (int i = 0; i < removeCount; ++i) { outputs[3].Append(addRemoveCollection.Remove() + " "); outputs[4].Append(myList.Remove() + " "); } for (int i = 0; i < 5; ++i) { Console.WriteLine(outputs[i].ToString().TrimEnd()); } Console.ReadKey(); }