public static void Main(string[] args)
        {
            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());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var addCollect       = new AddCollection();
            var removeAddCollect = new RemoveAddCollection();
            var myList           = new MyList();
            var inputStrings     = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < 3; i++)
            {
                for (int s = 0; s < inputStrings.Length; s++)
                {
                    switch (i)
                    {
                    case 0:
                        Console.Write(addCollect.Add(inputStrings[s]) + " ");
                        break;

                    case 1:
                        Console.Write(removeAddCollect.Add(inputStrings[s]) + " ");
                        break;

                    case 2:
                        Console.Write(myList.Add(inputStrings[s]) + " ");
                        break;
                    }
                }
                Console.WriteLine();
            }
            var countOfRemoves = int.Parse(Console.ReadLine());

            for (int i = 0; i < countOfRemoves; i++)
            {
                Console.Write(removeAddCollect.Remove() + " ");
            }
            Console.WriteLine();
            for (int i = 0; i < countOfRemoves; i++)
            {
                Console.Write(myList.Remove() + " ");
            }
        }