Example #1
0
        static void Main(string[] args)
        {
            AddCollection <string> addCollection = new AddCollection <string>();

            AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>();

            MyList <string> myList = new MyList <string>();

            string[] elements = Console.ReadLine().Split();
            int      removeOperationsCount = int.Parse(Console.ReadLine());

            int[,] indexes = new int[3, elements.Length];
            for (int col = 0; col < elements.Length; col++)
            {
                string element = elements[col];
                indexes[0, col] = addCollection.AddElement(element);
                indexes[1, col] = addRemoveCollection.AddElement(element);
                indexes[2, col] = myList.AddElement(element);
            }
            string[,] stringRemoveElements = new string[2, removeOperationsCount];
            for (int col = 0; col < removeOperationsCount; col++)
            {
                stringRemoveElements[0, col] = addRemoveCollection.Remove();
                stringRemoveElements[1, col] = myList.Remove();
            }

            PrintIndexes(indexes);
            PrintRemovedElements(stringRemoveElements);

            //foreach (var element in elements)
            //{
            //    Console.Write(addCollection.AddElement(element) + " ");
            //    addRemoveCollection.AddElement(element);
            //}
            //Console.WriteLine();
            //foreach (var element in elements)
            //{
            //    Console.Write(addRemoveCollection.AddElement(element) + " ");
            //}
            //Console.WriteLine();
            //foreach (var element in elements)
            //{
            //    Console.Write(myList.AddElement(element) + " ");
            //}
            //Console.WriteLine();
            //for (int i = 0; i < removeOperationsCount; i++)
            //{
            //    Console.Write(addRemoveCollection.Remove() + " ");
            //}
            //Console.WriteLine();
            //for (int i = 0; i < removeOperationsCount; i++)
            //{
            //    Console.Write(myList.Remove() + " ");
            //}
        }
        public void Run()
        {
            string[] elementsToAdd = Console.ReadLine()
                                     .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                     .ToArray();

            AddCollection       addCollection       = new AddCollection();
            AddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            MyList myList = new MyList();

            List <int> firstIndexes  = new List <int>();
            List <int> secondIndexes = new List <int>();
            List <int> thirdIndexes  = new List <int>();

            foreach (string element in elementsToAdd)
            {
                int first = addCollection.AddElement(element);
                firstIndexes.Add(first);

                int second = addRemoveCollection.AddElement(element);
                secondIndexes.Add(second);

                int third = myList.AddElement(element);
                thirdIndexes.Add(third);
            }

            Console.WriteLine(string.Join(" ", firstIndexes));
            Console.WriteLine(string.Join(" ", secondIndexes));
            Console.WriteLine(string.Join(" ", thirdIndexes));

            List <string> secondElements = new List <string>();
            List <string> thirdElements  = new List <string>();

            int numberOfCommands = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfCommands; i++)
            {
                string secondElement = addRemoveCollection.RemoveElement();
                secondElements.Add(secondElement);

                string thirdElement = myList.RemoveElement();
                thirdElements.Add(thirdElement);
            }

            Console.WriteLine(string.Join(" ", secondElements));
            Console.WriteLine(string.Join(" ", thirdElements));
        }