Beispiel #1
0
        public static void Main()
        {
            string[] amountOfStrings = Console.ReadLine().Split(new char[] { }, StringSplitOptions.RemoveEmptyEntries);
            AddCollection <string>       addCollection       = new AddCollection <string>();
            AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>();
            MyList <string> myList = new MyList <string>();

            for (int i = 0; i < amountOfStrings.Length; i++)
            {
                addCollection.Add(amountOfStrings[i]);
                addRemoveCollection.Add(amountOfStrings[i]);
                myList.Add(amountOfStrings[i]);
            }

            Console.WriteLine(addCollection);
            Console.WriteLine(addRemoveCollection);
            Console.WriteLine(myList);

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

            for (int i = 0; i < removeElement; i++)
            {
                addRemoveCollection.Remove();
                myList.Remove();
            }

            Console.WriteLine(addRemoveCollection.RemoveCollection(removeElement));
            Console.WriteLine(myList.RemoveCollection(removeElement));
        }
Beispiel #2
0
        public static void Main()
        {
            var input  = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            int remove = int.Parse(Console.ReadLine());
            var sb     = new StringBuilder();

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

            foreach (var item in input)
            {
                sb.Append(addCollection.Add(item) + " ");
            }
            sb.AppendLine();

            foreach (var item in input)
            {
                sb.Append(addRemoveCollection.Add(item) + " ");
            }
            sb.AppendLine();

            foreach (var item in input)
            {
                sb.Append(myList.Add(item) + " ");
            }
            sb.AppendLine();

            sb.Append(addRemoveCollection.Remove(remove));
            sb.Append(myList.Remove(remove));

            Console.WriteLine(sb);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            AddCollection       addCollection       = new AddCollection();
            AddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            MyList myList = new MyList();

            string[] inputParts = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string part in inputParts)
            {
                addCollection.Add(part);
                addRemoveCollection.Add(part);
                myList.Add(part);
            }

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

            for (int i = 0; i < elementsToRemove; i++)
            {
                addRemoveCollection.Remove();
                myList.Remove();
            }

            Console.WriteLine(addCollection);
            Console.WriteLine(addRemoveCollection);
            Console.WriteLine(myList);
            addRemoveCollection.GetRemovedElements();
            myList.GetRemovedElements();
        }
Beispiel #4
0
        public static void Main()
        {
            var input       = Console.ReadLine().Split();
            var countRemove = int.Parse(Console.ReadLine());

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

            ProcessAdd(input, addCollection, addRemoveCollection, myList);
            ProcessRemove(countRemove, addRemoveCollection, myList);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            var addColl    = new AddCollection();
            var addRemColl = new AddRemoveCollection();
            var myList     = new MyList();

            string[] input             = Console.ReadLine().Split();
            int      elementsToDiscard = int.Parse(Console.ReadLine());

            AddInputToLists(addColl, addRemColl, myList, input);
            RemoveElementsFromLists(addRemColl, myList, elementsToDiscard);
        }
        static void Main()
        {
            var strings = Console.ReadLine().Split();
            int numberOfRemoveOperations = int.Parse(Console.ReadLine());

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

            var sbAddCollOutput = new StringBuilder();

            foreach (var item in strings)
            {
                sbAddCollOutput.Append(addCollection.Add(item) + " ");
            }

            var sbAddRemCollOutput = new StringBuilder();

            foreach (var item in strings)
            {
                sbAddRemCollOutput.Append(addRemoveCollection.Add(item) + " ");
            }

            var sbMyListOutput = new StringBuilder();

            foreach (var item in strings)
            {
                sbMyListOutput.Append(myList.Add(item) + " ");
            }

            var sbAddRemCollRemovedItems = new StringBuilder();

            for (int i = 0; i < numberOfRemoveOperations; i++)
            {
                sbAddRemCollRemovedItems.Append(addRemoveCollection.Remove() + " ");
            }

            var sbMyListRemovedItems = new StringBuilder();

            for (int i = 0; i < numberOfRemoveOperations; i++)
            {
                sbMyListRemovedItems.Append(myList.Remove() + " ");
            }

            Console.WriteLine(sbAddCollOutput.ToString().TrimEnd());
            Console.WriteLine(sbAddRemCollOutput.ToString().TrimEnd());
            Console.WriteLine(sbMyListOutput.ToString().TrimEnd());
            Console.WriteLine(sbAddRemCollRemovedItems.ToString().TrimEnd());
            Console.WriteLine(sbMyListRemovedItems.ToString().TrimEnd());
        }
Beispiel #7
0
        public static void Main()
        {
            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 #8
0
        public static void Main()
        {
            var result = new List <string>();

            IListCollection      addCollection       = new AddCollection();
            IAddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            IMyList myListCollection = new MyList();

            var listOfCollections = new List <IListCollection>()
            {
                addCollection, addRemoveCollection, myListCollection
            };

            var data = Console.ReadLine().Split(' ');

            for (int i = 0; i < 3; i++)
            {
                string addedIndexes = "";
                foreach (var @string in data)
                {
                    int index = listOfCollections[i].Add(@string);
                    addedIndexes += index.ToString() + " ";
                }
                result.Add(addedIndexes.Trim());
            }

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

            string lineRemovedInfo = "";

            for (int i = 0; i < removingOperationsCount; i++)
            {
                lineRemovedInfo += addRemoveCollection.Remove() + " ";
            }
            result.Add(lineRemovedInfo.Trim());

            lineRemovedInfo = "";
            for (int i = 0; i < removingOperationsCount; i++)
            {
                lineRemovedInfo += myListCollection.Remove() + " ";
            }
            result.Add(lineRemovedInfo.Trim());


            foreach (var line in result)
            {
                Console.WriteLine(line);
            }
        }
        public static void Main()
        {
            AddCollection       addCollection       = new AddCollection();
            AddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            MyList myList = new MyList();

            string[] input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            Console.WriteLine(string.Join(" ", addCollection.Add(input)));
            Console.WriteLine(string.Join(" ", addRemoveCollection.Add(input)));
            Console.WriteLine(string.Join(" ", myList.Add(input)));

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

            Console.WriteLine(string.Join(" ", myList.Remove(countRemove)));
            Console.WriteLine(string.Join(" ", addRemoveCollection.Remove(countRemove)));
        }
        static void Main(string[] args)
        {
            string[] input       = Console.ReadLine().Split();
            int      removeCount = int.Parse(Console.ReadLine());

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

            AddElementsInCollection(addCollection, input);
            AddElementsInCollection(addRemoveCollection, input);
            AddElementsInCollection(myList, input);

            RemoveElemetnInCollection(addRemoveCollection, removeCount);
            RemoveElemetnInCollection(myList, removeCount);
        }
Beispiel #11
0
        static void AddInputToLists(AddCollection addColl, AddRemoveCollection addRemColl, MyList myList, string[] input)
        {
            var sbAddColl    = new StringBuilder();
            var sbAddRemColl = new StringBuilder();
            var sbMyList     = new StringBuilder();

            for (int i = 0; i < input.Length; i++)
            {
                string token = input[i];
                sbAddColl.Append(addColl.Add(token) + " ");
                sbAddRemColl.Append(addRemColl.Add(token) + " ");
                sbMyList.Append(myList.Add(token) + " ");
            }

            Console.WriteLine(sbAddColl.ToString().Trim());
            Console.WriteLine(sbAddRemColl.ToString().Trim());
            Console.WriteLine(sbMyList.ToString().Trim());
        }
Beispiel #12
0
        public void Run()
        {
            string[] input = Console.ReadLine()
                             .Split(" ", StringSplitOptions.RemoveEmptyEntries);

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

            string[] acOutput  = new string[input.Length];
            string[] arcOutput = new string[input.Length];
            string[] myOutput  = new string[input.Length];

            for (int i = 0; i < input.Length; i++)
            {
                acOutput[i]  = addCollection.Add(input[i]).ToString();
                arcOutput[i] = addRemoveCollection.Add(input[i]).ToString();
                myOutput[i]  = myList.Add(input[i]).ToString();
            }

            Console.WriteLine(String.Join(" ", acOutput));
            Console.WriteLine(String.Join(" ", arcOutput));
            Console.WriteLine(String.Join(" ", myOutput));

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

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

            Console.WriteLine();

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

            Console.WriteLine();
        }
Beispiel #13
0
        public static void Main()
        {
            string[] words = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

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

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

            foreach (var word in words)
            {
                Console.Write($"{addCollection.Add(word)} ");
            }
            Console.WriteLine();

            foreach (var word in words)
            {
                Console.Write($"{addRemoveCollection.Add(word)} ");
            }
            Console.WriteLine();

            foreach (var word in words)
            {
                Console.Write($"{myListCollection.Add(word)} ");
            }
            Console.WriteLine();

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

            for (int i = 0; i < removes; i++)
            {
                Console.Write($"{myListCollection.Remove()} ");
            }
            Console.WriteLine();
        }
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();

            IAddable   addList       = new AddCollection();
            IRemovable addRemoveList = new AddRemoveCollection();
            IUsable    myList        = new MyList();

            foreach (var str in input)
            {
                Console.Write(addList.Add(str) + " ");
            }
            Console.WriteLine();
            foreach (var str in input)
            {
                Console.Write(addRemoveList.Add(str) + " ");
            }
            Console.WriteLine();
            foreach (var str in input)
            {
                Console.Write(myList.Add(str) + " ");
            }
            Console.WriteLine();

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


            for (int j = 0; j < removesCount; j++)
            {
                Console.Write(addRemoveList.Remove() + " ");
            }
            Console.WriteLine();
            for (int j = 0; j < removesCount; j++)
            {
                Console.Write(myList.Remove() + " ");
            }
            Console.WriteLine();
        }
Beispiel #15
0
        public static void Main()
        {
            var addCollevtion       = new AddCollection();
            var addRamoveCollection = new AddRemoveCollection();
            var myList = new MyList();

            var input = Console.ReadLine()
                        .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var addCollAdds       = new byte[input.Length];
            var addRemoveCollAdds = new byte[input.Length];
            var myListAdds        = new byte[input.Length];

            for (int i = 0; i < input.Length; i++)
            {
                addCollAdds[i]       = addCollevtion.Add(input[i]);
                addRemoveCollAdds[i] = addRamoveCollection.Add(input[i]);
                myListAdds[i]        = myList.Add(input[i]);
            }

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

            var addRemoveCollRemoves = new string[numberOfRemoves];
            var myListRemoves        = new string[numberOfRemoves];

            for (int i = 0; i < numberOfRemoves; i++)
            {
                addRemoveCollRemoves[i] = addRamoveCollection.Remove();
                myListRemoves[i]        = myList.Remove();
            }

            Console.WriteLine(string.Join(" ", addCollAdds));
            Console.WriteLine(string.Join(" ", addRemoveCollAdds));
            Console.WriteLine(string.Join(" ", myListAdds));
            Console.WriteLine(string.Join(" ", addRemoveCollRemoves));
            Console.WriteLine(string.Join(" ", myListRemoves));
        }