public static void Main() { string[] input = Console.ReadLine().Split(); AddCollection addCollection = new AddCollection(); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); MyList myList = new MyList(); List <int> addAddCollection = new List <int>(); List <int> addAddRemoveCollection = new List <int>(); List <int> addMyList = new List <int>(); foreach (var item in input) { addAddCollection.Add(addCollection.Add(item)); addAddRemoveCollection.Add(addRemoveCollection.Add(item)); addMyList.Add(myList.Add(item)); } List <string> removeAddRemoveCollection = new List <string>(); List <string> removeMyList = new List <string>(); int numberRemove = int.Parse(Console.ReadLine()); for (int i = 0; i < numberRemove; i++) { removeAddRemoveCollection.Add(addRemoveCollection.RemoveElement()); removeMyList.Add(myList.RemoveElement()); } Console.WriteLine(string.Join(" ", addAddCollection)); Console.WriteLine(string.Join(" ", addAddRemoveCollection)); Console.WriteLine(string.Join(" ", addMyList)); Console.WriteLine(string.Join(" ", removeAddRemoveCollection)); Console.WriteLine(string.Join(" ", removeMyList)); }
public static void Main() { List <string> input = Console.ReadLine().Split().ToList(); AddCollection addCollection = new AddCollection(); List <int> list = AddElements(input, addCollection); Console.WriteLine(string.Join(" ", list)); AddRemoveCollection addRemoveCollection = new AddRemoveCollection(); list = AddElements(input, addRemoveCollection); Console.WriteLine(string.Join(" ", list)); MyList myList = new MyList(); list = AddElements(input, myList); Console.WriteLine(string.Join(" ", list)); int numberOfRemoves = int.Parse(Console.ReadLine()); List <string> deletedElements = new List <string>(); deletedElements = RemoveElements(numberOfRemoves, addRemoveCollection); Console.WriteLine(string.Join(" ", deletedElements)); deletedElements = RemoveElements(numberOfRemoves, myList); Console.WriteLine(string.Join(" ", deletedElements)); }
static void Main(string[] args) { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var input = Console.ReadLine().Split(); var numberOfRemovals = int.Parse(Console.ReadLine()); Console.WriteLine(addCollection.Add(input)); Console.WriteLine(addRemoveCollection.Add(input)); Console.WriteLine(myList.Add(input)); Console.WriteLine(addRemoveCollection.Remove(numberOfRemovals)); Console.WriteLine(myList.Remove(numberOfRemovals)); }
public static void Main() { var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var input = Console.ReadLine().Split(); foreach (string element in input) { Console.Write($"{addCollection.Add(element)} "); } Console.WriteLine(); foreach (string element in input) { Console.Write($"{addRemoveCollection.Add(element)} "); } Console.WriteLine(); foreach (string element in input) { Console.Write($"{myList.Add(element)} "); } Console.WriteLine(); 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(); }
static void Main(string[] args) { AddCollection ac = new AddCollection(); AddRemoveCollection arc = new AddRemoveCollection(); MyList ml = new MyList(); var input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); 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(); }
static void Main() { var elements = Console.ReadLine().Split(); var addCollection = new AddCollection(); var addRemoveCollection = new AddRemoveCollection(); var myList = new MyList(); var addCollectionIndices = new List <int>(); var removableCollectionsIndices = new List <int>(); foreach (var element in elements) { addCollectionIndices.Add(addCollection.Add(element)); addRemoveCollection.Add(element); myList.Add(element); removableCollectionsIndices.Add(0); } var countOfRemoveOperations = int.Parse(Console.ReadLine()); var addRemoveCollectionRemovedElements = new List <string>(); var myListRemovedElements = new List <string>(); for (int counter = 0; counter < countOfRemoveOperations; counter++) { addRemoveCollectionRemovedElements.Add(addRemoveCollection.Remove()); myListRemovedElements.Add(myList.Remove()); } Console.WriteLine(string.Join(' ', addCollectionIndices)); Console.WriteLine(string.Join(' ', removableCollectionsIndices)); Console.WriteLine(string.Join(' ', removableCollectionsIndices)); Console.WriteLine(string.Join(' ', addRemoveCollectionRemovedElements)); Console.WriteLine(string.Join(' ', myListRemovedElements)); }