Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            string[] words          = Console.ReadLine().Split();
            int      removeOpsCount = int.Parse(Console.ReadLine());

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

            foreach (var item in words)
            {
                Console.Write(addCollection.Add(item) + " ");
            }

            Console.WriteLine();

            foreach (var item in words)
            {
                Console.Write(addRemoveCollection.Add(item) + " ");
            }

            Console.WriteLine();

            foreach (var item in words)
            {
                Console.Write(myList.Add(item) + " ");
            }

            Console.WriteLine();

            for (int i = 0; i < removeOpsCount; i++)
            {
                Console.Write(addRemoveCollection.Remove() + " ");
            }

            Console.WriteLine();

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

            Console.WriteLine();
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            IAddCollection <string>       addColletion     = new AddCollection <string>();
            IAddRemoveCollection <string> addRemCollection = new AddRemoveCollection <string>();
            IMyList <string> myList = new MyList <string>();

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

            var addCollAddIndexes    = new StringBuilder();
            var addRemCollAddIndexes = new StringBuilder();
            var myListCollAddIndexes = new StringBuilder();

            foreach (var item in itemsToAdd)
            {
                addCollAddIndexes.Append($"{addColletion.Add(item)} ");
                addRemCollAddIndexes.Append($"{addRemCollection.Add(item)} ");
                myListCollAddIndexes.Append($"{myList.Add(item)} ");
            }

            var addRemCollRemoveElements = new StringBuilder();
            var myListRemoveElements     = new StringBuilder();

            for (int i = 0; i < removeOperationsCount; i++)
            {
                addRemCollRemoveElements.Append($"{addRemCollection.Remove()} ");
                myListRemoveElements.Append($"{myList.Remove()} ");
            }

            Console.WriteLine(addCollAddIndexes.ToString().Trim());
            Console.WriteLine(addRemCollAddIndexes.ToString().Trim());
            Console.WriteLine(myListCollAddIndexes.ToString().Trim());

            Console.WriteLine(addRemCollRemoveElements.ToString().Trim());
            Console.WriteLine(myListRemoveElements.ToString().Trim());
        }