Exemple #1
0
        static void Main(string[] args)
        {
            var addCollection       = new AddCollection();
            var addRemoveCollection = new AddRemoveCollection();
            var myList = new MyList();

            var indexesAddCollection = new List <int>();
            var indexesAddRemove     = new List <int>();
            var indexesMyList        = new List <int>();

            var elementsToAdd = Console.ReadLine().Split();

            int insertAt;

            foreach (var element in elementsToAdd)
            {
                insertAt = addCollection.Add(element);
                indexesAddCollection.Add(insertAt);

                insertAt = addRemoveCollection.Add(element);
                indexesAddRemove.Add(insertAt);

                insertAt = myList.Add(element);
                indexesMyList.Add(insertAt);
            }

            var countOfElementsToRemove = int.Parse(Console.ReadLine());

            var removedFromRemoveAndAdd = new List <string>();
            var removedFromMyList       = new List <string>();

            string removedItem;

            for (int i = 0; i < countOfElementsToRemove; i++)
            {
                removedItem = addRemoveCollection.Remove();
                removedFromRemoveAndAdd.Add(removedItem);

                removedItem = myList.Remove();
                removedFromMyList.Add(removedItem);
            }

            Console.WriteLine(string.Join(' ', indexesAddCollection));
            Console.WriteLine(string.Join(' ', indexesAddRemove));
            Console.WriteLine(string.Join(' ', indexesMyList));

            Console.WriteLine(string.Join(' ', removedFromRemoveAndAdd));
            Console.WriteLine(string.Join(' ', removedFromMyList));
        }
Exemple #2
0
        public static void Main()
        {
            var addCollection       = new AddCollection <string>();
            var addRemoveCollection = new AddRemoveCollection <string>();
            var myList = new MyList <string>();

            var addIndicesAddCollection       = String.Empty;
            var addIndicesAddRemoveCollection = String.Empty;
            var addIndicesMyList = String.Empty;

            var elements = Console.ReadLine().Split();

            int indexOfAdding;

            foreach (var element in elements)
            {
                indexOfAdding            = addCollection.Add(element);
                addIndicesAddCollection += $"{indexOfAdding} ";

                indexOfAdding = addRemoveCollection.Add(element);
                addIndicesAddRemoveCollection += $"{indexOfAdding} ";

                indexOfAdding     = myList.Add(element);
                addIndicesMyList += $"{indexOfAdding} ";
            }

            var amountOfRemoves = int.Parse(Console.ReadLine());

            var removedItemFromAddRemoveCollection = String.Empty;
            var removedItemFromMyList = String.Empty;

            var 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());
        }
Exemple #3
0
        public static void Main()
        {
            var addCollection       = new AddCollection();
            var addRemoveCollection = new AddRemoveCollection();
            var myList = new MyList();

            var input = Console.ReadLine().Split();
            int removeOperationsCount = int.Parse(Console.ReadLine());

            foreach (string item in input)
            {
                Console.Write(addCollection.Add(item) + " ");
            }

            Console.WriteLine();

            foreach (string item in input)
            {
                Console.Write(addRemoveCollection.Add(item) + " ");
            }

            Console.WriteLine();

            foreach (string item in input)
            {
                Console.Write(myList.Add(item) + " ");
            }

            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() + " ");
            }

            Console.WriteLine();
        }
        static void Main()
        {
            IAddCollection       addcollection       = new AddCollection();
            IAddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            IMyList myList = new MyList();

            var input = Console.ReadLine().Split();

            FillCollection(input, addcollection);
            FillCollection(input, addRemoveCollection);
            FillCollection(input, myList);

            var numberOfRemovals = int.Parse(Console.ReadLine());

            RemoveOperation(numberOfRemovals, addRemoveCollection);
            RemoveOperation(numberOfRemovals, myList);

            Console.WriteLine(resultingOutput.ToString().Trim());
        }