Esempio n. 1
0
    static void Main()
    {
        var list = new AddRemoveCollection();

        list.Add("PEsho");
        list.Add("tt");
        list.Add("bb");

        Console.WriteLine(list.Remove());
    }
Esempio n. 2
0
        public void Run()
        {
            IAddCollection <string>       addCollection       = new AddCollection <string>();
            IAddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>();
            IMyList <string> myList = new MyList <string>();

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

            foreach (var str in addTokens)
            {
                addCollection.Add(str);
                addRemoveCollection.Add(str);
                myList.Add(str);
            }

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

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

            var resultsARC = new List <string>();
            var resultsML  = new List <string>();

            for (int i = 0; i < n; i++)
            {
                resultsARC.Add(addRemoveCollection.Remove());
                resultsML.Add(myList.Remove());
            }

            Console.WriteLine(string.Join(" ", resultsARC));
            Console.WriteLine(string.Join(" ", resultsML));
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            string[] input            = Console.ReadLine().Split();
            int      removeOperations = int.Parse(Console.ReadLine());

            AddCollection <string>       myAddColl       = new AddCollection <string>();
            AddRemoveCollection <string> myAddRemoveColl = new AddRemoveCollection <string>();
            MyList <string> myList = new MyList <string>();

            List <int> addIndexes       = new List <int>();
            List <int> addRemoveIndexes = new List <int>();
            List <int> myListIndexes    = new List <int>();

            for (int index = 0; index < input.Length; index++)
            {
                addIndexes.Add(myAddColl.Add(input[index]));
                addRemoveIndexes.Add(myAddRemoveColl.Add(input[index]));
                myListIndexes.Add(myList.Add(input[index]));
            }

            List <string> addRemoves    = new List <string>();
            List <string> myListRemoves = new List <string>();

            for (int removeIndex = 0; removeIndex < removeOperations; removeIndex++)
            {
                addRemoves.Add(myAddRemoveColl.Remove());
                myListRemoves.Add(myList.Remove());
            }

            Console.WriteLine(string.Join(" ", addIndexes));
            Console.WriteLine(string.Join(" ", addRemoveIndexes));
            Console.WriteLine(string.Join(" ", myListIndexes));
            Console.WriteLine(string.Join(" ", addRemoves));
            Console.WriteLine(string.Join(" ", myListRemoves));
        }
Esempio n. 4
0
    static void Main(string[] args)
    {
        var addCollection       = new AddCollection();
        var addRemoveCollection = new AddRemoveCollection();
        var myList = new MyList();

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

        List <int>    addCollectionResults       = new List <int>();
        List <int>    addRemoveCollectionResults = new List <int>();
        List <int>    myListResults = new List <int>();
        List <string> addRemoveCollectionRemoves = new List <string>();
        List <string> myListRemoves = new List <string>();

        foreach (string element in elements)
        {
            addCollectionResults.Add(addCollection.Add(element));
            addRemoveCollectionResults.Add(addRemoveCollection.Add(element));
            myListResults.Add(myList.Add(element));
        }

        for (int counter = 0; counter < count; counter++)
        {
            addRemoveCollectionRemoves.Add(addRemoveCollection.Remove());
            myListRemoves.Add(myList.Remove());
        }

        Console.WriteLine(string.Join(" ", addCollectionResults));
        Console.WriteLine(string.Join(" ", addRemoveCollectionResults));
        Console.WriteLine(string.Join(" ", myListResults));
        Console.WriteLine(string.Join(" ", addRemoveCollectionRemoves));
        Console.WriteLine(string.Join(" ", myListRemoves));
    }
Esempio n. 5
0
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int      removedOperationsNumber = int.Parse(Console.ReadLine());

            AddCollection addCollection        = new AddCollection();
            List <int>    addCollectionResults = new List <int>();

            AddRemoveCollection addRemoveCollection              = new AddRemoveCollection();
            List <int>          addRemoveCollectonAddResults     = new List <int>();
            List <string>       addRemoveCollectionRemoveResults = new List <string>();

            MyList        myList              = new MyList();
            List <int>    myListAddResults    = new List <int>();
            List <string> myListRemoveResults = new List <string>();

            foreach (var item in input)
            {
                addCollectionResults.Add(addCollection.Add(item));
                addRemoveCollectonAddResults.Add(addRemoveCollection.Add(item));
                myListAddResults.Add(myList.Add(item));
            }

            for (int i = 0; i < removedOperationsNumber; i++)
            {
                addRemoveCollectionRemoveResults.Add(addRemoveCollection.Remove());
                myListRemoveResults.Add(myList.Remove());
            }

            Console.WriteLine(string.Join(" ", addCollectionResults));
            Console.WriteLine(string.Join(" ", addRemoveCollectonAddResults));
            Console.WriteLine(string.Join(" ", myListAddResults));
            Console.WriteLine(string.Join(" ", addRemoveCollectionRemoveResults));
            Console.WriteLine(string.Join(" ", myListRemoveResults));
        }
Esempio n. 6
0
        public static void Main(string[] args)
        {
            var addCollection       = new AddCollection();
            var addRemoveCollection = new AddRemoveCollection();
            var myList = new MyList();

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

            foreach (var item in input)
            {
                Console.Write(addCollection.Add(item) + " ");
            }
            Console.WriteLine();
            foreach (var item in input)
            {
                Console.Write(addRemoveCollection.Add(item) + " ");
            }
            Console.WriteLine();
            foreach (var item in input)
            {
                Console.Write(myList.Add(item) + " ");
            }
            Console.WriteLine();
            for (int i = 0; i < removeCount; i++)
            {
                Console.Write(addRemoveCollection.Remove() + " ");
            }
            Console.WriteLine();
            for (int i = 0; i < removeCount; i++)
            {
                Console.Write(myList.Remove() + " ");
            }
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            AddCollection       addCollection       = new AddCollection();
            AddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            MyList myList             = new MyList();
            var    firstSbCollection  = new StringBuilder();
            var    secondSbCollection = new StringBuilder();
            var    thirdSbCollection  = new StringBuilder();
            var    firstRemoveItems   = new StringBuilder();
            var    secondRemoveItems  = new StringBuilder();
            var    collection         = Console.ReadLine()
                                        .Split(' ')
                                        .ToList();

            for (int i = 0; i < collection.Count; i++)
            {
                firstSbCollection.Append(addCollection.Add(collection[i]) + " ");
                secondSbCollection.Append(addRemoveCollection.Add(collection[i]) + " ");
                thirdSbCollection.Append(myList.Add(collection[i]) + " ");
            }
            var numberOfRemovedItems = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfRemovedItems; i++)
            {
                firstRemoveItems.Append(addRemoveCollection.Remove() + " ");
                secondRemoveItems.Append(myList.Remove() + " ");
            }
            Console.WriteLine(firstSbCollection);
            Console.WriteLine(secondSbCollection);
            Console.WriteLine(thirdSbCollection);
            Console.WriteLine(firstRemoveItems);
            Console.WriteLine(secondRemoveItems);
        }
Esempio n. 8
0
    private static void Main()
    {
        string[] elements = Console.ReadLine().Split();

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

        foreach (string element in elements)
        {
            addCollection.Add(element);
            addRemoveCollection.Add(element);
            myList.Add(element);
        }
        Console.WriteLine(addCollection.AddIndexes);
        Console.WriteLine(addRemoveCollection.AddIndexes);
        Console.WriteLine(myList.AddIndexes);

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

        for (int i = 1; i <= elementToRemove; i++)
        {
            addRemoveCollection.Remove();
            myList.Remove();
        }

        Console.WriteLine(addRemoveCollection.RemovedElements);
        Console.WriteLine(myList.RemovedElements);
    }
Esempio n. 9
0
        public void Run()
        {
            string[] input = Console
                             .ReadLine()
                             .Split(' ', StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < input.Length; i++)
            {
                addCollectionItems.Add(input[i]);
                addRemoveCollectionItems.Add(input[i]);
                myListItems.Add(input[i]);
            }

            addCollectionItems.PrintAddedIndexes();
            addRemoveCollectionItems.PrintAddedIndexes();
            myListItems.PrintAddedIndexes();

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

            for (int i = 0; i < itemsToRemove; i++)
            {
                addRemoveCollectionItems.Remove();
                myListItems.Remove();
            }

            myListItems.PrintRemovedItems();
            addRemoveCollectionItems.PrintRemovedItems();
        }
Esempio n. 10
0
        public void Run()
        {
            string[] elements = Console.ReadLine().Split();
            int      n        = int.Parse(Console.ReadLine());

            foreach (var element in elements)
            {
                addCollectionResult.Add(addCollection.Add(element));
                addRemoveCollectionResult.Add(addRemoveCollection.Add(element));
                myListResult.Add(myList.Add(element));
            }

            for (int i = 0; i < n; i++)
            {
                addRemoveCollectionRemoves.Add(addRemoveCollection.Remove());
                myListRemoves.Add(myList.Remove());
            }

            foreach (var item in resultInts)
            {
                Console.WriteLine(string.Join(" ", item));
            }
            foreach (var item in resultStrings)
            {
                Console.WriteLine(string.Join(" ", item));
            }
        }
Esempio n. 11
0
    public static void Main()
    {
        AddCollection <string>       addCollection       = new AddCollection <string>();
        AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>();
        MyList <string> mylist = new MyList <string>();

        StringBuilder addOpsAddcollection       = new StringBuilder();
        StringBuilder addOpsAddRemoveCollection = new StringBuilder();
        StringBuilder addOpsMylist = new StringBuilder();
        StringBuilder removeAddRemoveCollection = new StringBuilder();
        StringBuilder removeOpsMyList           = new StringBuilder();

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

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

        foreach (string item in tokens)
        {
            addOpsAddcollection.Append(addCollection.Add(item) + " ");
            addOpsAddRemoveCollection.Append(addRemoveCollection.Add(item) + " ");
            addOpsMylist.Append(mylist.Add(item) + " ");
        }

        for (int i = 0; i < removeOpsCount; i++)
        {
            removeAddRemoveCollection.Append(addRemoveCollection.Remove() + " ");
            removeOpsMyList.Append(mylist.Remove() + " ");
        }

        PrintResult(addOpsAddcollection, addOpsAddRemoveCollection, addOpsMylist, removeAddRemoveCollection,
                    removeOpsMyList);
    }
Esempio n. 12
0
        public static void Main()
        {
            IAddCollection <string>       addColection       = new AddCollection <string>();
            IAddRemoveCollection <string> addRemoveColection = new AddRemoveCollection <string>();
            IMyList <string> myList = new MyList <string>();

            var addCollIndexes    = new StringBuilder();
            var addRemCollIndexes = new StringBuilder();
            var myListIndexes     = new StringBuilder();
            var tokens            = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var elem in tokens)
            {
                addCollIndexes.Append($"{addColection.Add(elem)} ");
                addRemCollIndexes.Append($"{addRemoveColection.Add(elem)} ");
                myListIndexes.Append($"{myList.Add(elem)} ");
            }

            var addRemcCollRemovedItems = new StringBuilder();
            var myListRemovedItems      = new StringBuilder();
            var removeCount             = int.Parse(Console.ReadLine());

            for (int i = 0; i < removeCount; i++)
            {
                addRemcCollRemovedItems.Append($"{addRemoveColection.Remove()} ");
                myListRemovedItems.Append($"{myList.Remove()} ");
            }

            Console.WriteLine(addCollIndexes.ToString().Trim());
            Console.WriteLine(addRemCollIndexes.ToString().Trim());
            Console.WriteLine(myListIndexes.ToString().Trim());

            Console.WriteLine(addRemcCollRemovedItems.ToString().Trim());
            Console.WriteLine(myListRemovedItems.ToString().Trim());
        }
        public void Run()
        {
            string[] input       = Console.ReadLine().Split();
            int      removeCount = int.Parse(Console.ReadLine());


            for (int i = 0; i < input.Length; i++)
            {
                Console.Write(addCollection.Add(input[i]) + " ");
            }

            Console.WriteLine();
            for (int i = 0; i < input.Length; i++)
            {
                Console.Write(addRemoveCollection.Add(input[i]) + " ");
            }

            Console.WriteLine();
            for (int i = 0; i < input.Length; i++)
            {
                Console.Write(myList.Add(input[i]) + " ");
            }

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

            Console.WriteLine();
            for (int i = 0; i < removeCount; i++)
            {
                Console.Write(myList.Remove() + " ");
            }
        }
Esempio n. 14
0
    public static void Main()
    {
        IAddable    addCollection       = new AddCollection();
        ICollection addRemoveCollection = new AddRemoveCollection();
        IMyList     myList = new MyList();

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

        StringBuilder addCollectionAddOperationResults       = new StringBuilder();
        StringBuilder addRemoveCollectionAddOperationResults = new StringBuilder();
        StringBuilder myListAddOperationResults = new StringBuilder();

        foreach (var item in itemsForInsert)
        {
            addCollectionAddOperationResults.Append(addCollection.Add(item) + " ");
            addRemoveCollectionAddOperationResults.Append(addRemoveCollection.Add(item) + " ");
            myListAddOperationResults.Append(myList.Add(item) + " ");
        }
        Console.WriteLine(addCollectionAddOperationResults.ToString().Trim());
        Console.WriteLine(addRemoveCollectionAddOperationResults.ToString().Trim());
        Console.WriteLine(myListAddOperationResults.ToString().Trim());

        StringBuilder addRemoveCollectionRemoveOperationResults = new StringBuilder();
        StringBuilder myListRemoveOperationResults = new StringBuilder();
        int           numberOfRemoveOperations     = int.Parse(Console.ReadLine());

        for (int i = 0; i < numberOfRemoveOperations; i++)
        {
            addRemoveCollectionRemoveOperationResults.Append(addRemoveCollection.Remove() + " ");
            myListRemoveOperationResults.Append(myList.Remove() + " ");
        }
        Console.WriteLine(addRemoveCollectionRemoveOperationResults.ToString().Trim());
        Console.WriteLine(myListRemoveOperationResults.ToString().Trim());
    }
Esempio n. 15
0
        public static void Main()
        {
            var                 elementsToAdd      = Console.ReadLine().Split().ToList();
            var                 countOfRemoveOps   = int.Parse(Console.ReadLine());
            AddCollection       addCollection      = new AddCollection();
            AddRemoveCollection addRemoveColletion = new AddRemoveCollection();
            MyList              myList             = new MyList();

            foreach (var elementToAdd in elementsToAdd)
            {
                Console.Write(addCollection.Add(elementToAdd) + " ");
            }
            Console.WriteLine();
            foreach (var elementToAdd in elementsToAdd)
            {
                Console.Write(addRemoveColletion.Add(elementToAdd) + " ");
            }
            Console.WriteLine();
            foreach (var elementToAdd in elementsToAdd)
            {
                Console.Write(myList.Add(elementToAdd) + " ");
            }
            Console.WriteLine();
            for (int i = 0; i < countOfRemoveOps; i++)
            {
                Console.Write(addRemoveColletion.Remove() + " ");
            }
            Console.WriteLine();
            for (int i = 0; i < countOfRemoveOps; i++)
            {
                Console.Write(myList.Remove() + " ");
            }
            Console.WriteLine();
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            int      countElementsToRemove = int.Parse(Console.ReadLine());

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

            List <int>    resultAddCollection       = new List <int>();
            List <int>    resultAddRemoveCollection = new List <int>();
            List <int>    resultMyList = new List <int>();
            List <string> resultRemovedAddRemoveCollection = new List <string>();
            List <string> resultRenovedMyList = new List <string>();

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

            for (int i = 0; i < countElementsToRemove; i++)
            {
                resultRemovedAddRemoveCollection.Add(addRemoveCollection.Remove());
                resultRenovedMyList.Add(myList.Remove());
            }

            Console.WriteLine(string.Join(' ', resultAddCollection));
            Console.WriteLine(string.Join(' ', resultAddRemoveCollection));
            Console.WriteLine(string.Join(' ', resultMyList));
            Console.WriteLine(string.Join(' ', resultRemovedAddRemoveCollection));
            Console.WriteLine(string.Join(' ', resultRenovedMyList));
        }
Esempio n. 17
0
        public static void Main()
        {
            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();
        }
Esempio n. 18
0
 private static void AddItem(AddCollection addCollection, AddRemoveCollection addRemoveCollection, MyList myList, List <string> elements)
 {
     foreach (var item in elements)
     {
         addCollection.Add(item);
         addRemoveCollection.Add(item);
         myList.Add(item);
     }
 }
Esempio n. 19
0
    private static void AddElements(AddCollection addCollection, AddRemoveCollection addRemoveCollection, MyList myList)
    {
        string[] elementsToAdd = Console.ReadLine().Split(' ');

        for (int i = 0; i < elementsToAdd.Length; i++)
        {
            if (i == elementsToAdd.Length - 1)
            {
                Console.Write(addCollection.Add(elementsToAdd[i]));
            }
            else
            {
                Console.Write(addCollection.Add(elementsToAdd[i]) + " ");
            }
        }
        Console.WriteLine();

        for (int i = 0; i < elementsToAdd.Length; i++)
        {
            if (i == elementsToAdd.Length - 1)
            {
                Console.Write(addRemoveCollection.Add(elementsToAdd[i]));
            }
            else
            {
                Console.Write(addRemoveCollection.Add(elementsToAdd[i]) + " ");
            }
        }
        Console.WriteLine();

        for (int i = 0; i < elementsToAdd.Length; i++)
        {
            if (i == elementsToAdd.Length - 1)
            {
                Console.Write(myList.Add(elementsToAdd[i]));
            }
            else
            {
                Console.Write(myList.Add(elementsToAdd[i]) + " ");
            }
        }
        Console.WriteLine();
    }
Esempio n. 20
0
 private void AddElementToCollection(string[] input, List <int> indexesAddCollection,
                                     List <int> indexesAddRemoveCollection, List <int> indexesMyList)
 {
     foreach (var item in input)
     {
         indexesAddCollection.Add(addCollection.Add(item));
         indexesAddRemoveCollection.Add(addRemoveCollection.Add(item));
         indexesMyList.Add(myList.Add(item));
     }
 }
Esempio n. 21
0
        private List <int> AddInAddRemoveCollection(List <string> input)
        {
            List <int> result = new List <int>();

            for (int i = 0; i < input.Count; i++)
            {
                result.Add(addRemoveCollection.Add(input[i]));
            }

            return(result);
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            int      m      = int.Parse(Console.ReadLine());
            int      n      = tokens.Length;

            AddCollection a = new AddCollection();

            for (int i = 0; i < n; i++)
            {
                Console.Write($"{a.Add(tokens[i])} ");
            }
            Console.WriteLine();



            AddRemoveCollection b = new AddRemoveCollection();

            for (int i = 0; i < n; i++)
            {
                Console.Write(b.Add(tokens[i]) + " ");
            }
            Console.WriteLine();



            MyList c = new MyList();

            for (int i = 0; i < n; i++)
            {
                Console.Write(c.Add(tokens[i]) + " ");
            }
            Console.WriteLine();



            for (int i = 0; i < m; i++)
            {
                Console.Write(b.Remove() + " ");
            }
            Console.WriteLine();

            for (int i = 0; i < m; i++)
            {
                Console.Write(c.Remove() + " ");
            }
            Console.WriteLine();

            Console.ReadKey();
        }
Esempio n. 23
0
        public static void Main()
        {
            string[] collection = Console.ReadLine().Split(' ').ToArray();

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

            var addCollection = new AddCollection();

            var addRemoveCollection = new AddRemoveCollection();

            var myList = new MyList();

            for (int i = 0; i < collection.Length; i++)
            {
                var index = addCollection.Add(collection[i]);
                Console.Write(index + " ");
            }

            Console.WriteLine();

            for (int i = 0; i < collection.Length; i++)
            {
                var index = addRemoveCollection.Add(collection[i]);
                Console.Write(index + " ");
            }

            Console.WriteLine();

            for (int i = 0; i < collection.Length; i++)
            {
                var index = myList.Add(collection[i]);
                Console.Write(index + " ");
            }

            Console.WriteLine();

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

            Console.WriteLine();

            for (int i = 0; i < removeCount; i++)
            {
                var index = myList.Remove();
                Console.Write(index + " ");
            }
        }
Esempio n. 24
0
        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());
        }
Esempio n. 25
0
        public static void Main()
        {
            string[] elementsForAdd   = Console.ReadLine().Split();
            int      countOfRemoveOps = int.Parse(Console.ReadLine());

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


            foreach (string elementForAdd in elementsForAdd)
            {
                int index = addCollection.Add(elementForAdd);
                Console.Write(index + " ");
                myList.Add(elementForAdd);
            }

            Console.WriteLine();

            foreach (string elementForAdd in elementsForAdd)
            {
                int index = addRemove.Add(elementForAdd);
                Console.Write(index + " ");
            }

            Console.WriteLine();

            foreach (string elementForAdd in elementsForAdd)
            {
                int index = myList.Add(elementForAdd);
                Console.Write(index + " ");
            }

            Console.WriteLine();

            for (int i = 0; i < countOfRemoveOps; i++)
            {
                string element = addRemove.Remove();
                Console.Write(element + " ");
            }

            Console.WriteLine();

            for (int i = 0; i < countOfRemoveOps; i++)
            {
                string element = myList.Remove();
                Console.Write(element + " ");
            }
        }
Esempio n. 26
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 AddIndex;

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

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

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

        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());
    }
Esempio n. 27
0
    public static void Main()
    {
        string[] strings = Console.ReadLine().Split().ToArray();

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

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

        foreach (var @string in strings)
        {
            Console.Write(addCollection.Add(@string) + " ");
        }

        Console.WriteLine();

        foreach (var @string in strings)
        {
            addRemoveCollection.Add(@string);
            Console.Write("0 ");
        }

        Console.WriteLine();

        foreach (var @string in strings)
        {
            myList.Add(@string);
            Console.Write("0 ");
        }

        Console.WriteLine();

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

        Console.WriteLine();

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

        Console.WriteLine();
    }
Esempio n. 28
0
        //-------------- Methods ------------------
        public void Run()
        {
            AddCollection <string>       addCollection       = new AddCollection <string>();
            AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>();
            MyList <string> myList = new MyList <string>();

            string[] data = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            int[,] indexMatrix = new int[3, data.Length];

            for (int col = 0; col < indexMatrix.GetLength(1); col++)
            {
                indexMatrix[0, col] = addCollection.Add(data[col]);
                indexMatrix[1, col] = addRemoveCollection.Add(data[col]);
                indexMatrix[2, col] = myList.Add(data[col]);
            }

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

            string[,] stringMatrix = new string[2, removeOperations];

            for (int col = 0; col < stringMatrix.GetLength(1); col++)
            {
                stringMatrix[0, col] = addRemoveCollection.Remove();
                stringMatrix[1, col] = myList.Remove();
            }

            //----------------------- PRINTING -------------------------
            for (int row = 0; row < indexMatrix.GetLength(0); row++)
            {
                string result = String.Empty;
                for (int i = 0; i < indexMatrix.GetLength(1); i++)
                {
                    result += indexMatrix[row, i] + " ";
                }
                Console.WriteLine(result.TrimEnd());
            }

            for (int row = 0; row < stringMatrix.GetLength(0); row++)
            {
                string result = String.Empty;
                for (int i = 0; i < stringMatrix.GetLength(1); i++)
                {
                    result += stringMatrix[row, i] + " ";
                }
                Console.WriteLine(result.TrimEnd());
            }
        }
Esempio n. 29
0
        public void Run()
        {
            AddCollection       addCollection       = new AddCollection();
            AddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            MyList myList = new MyList();

            string[] inputElements = this.reader.ReadLine()
                                     .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                     .ToArray();

            foreach (var item in inputElements)
            {
                this.writer.Write($"{addCollection.Add(item)} ");
            }

            this.writer.WriteLine();

            foreach (var item in inputElements)
            {
                this.writer.Write($"{addRemoveCollection.Add(item)} ");
            }

            this.writer.WriteLine();

            foreach (var item in inputElements)
            {
                this.writer.Write($"{myList.Add(item)} ");
            }

            this.writer.WriteLine();

            int count = int.Parse(this.reader.ReadLine());

            for (int i = 0; i < count; i++)
            {
                this.writer.Write($"{addRemoveCollection.Remove()} ");
            }

            this.writer.WriteLine();

            for (int i = 0; i < count; i++)
            {
                this.writer.Write($"{myList.Remove()} ");
            }

            this.writer.WriteLine();
        }
Esempio n. 30
0
    static void Main(string[] args)
    {
        AddCollection       ac  = new AddCollection();
        AddRemoveCollection arc = new AddRemoveCollection();
        MyList myList           = new MyList();

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

        List <int> result = new List <int>();

        foreach (var str in input)
        {
            result.Add(ac.Add(str));
        }
        Console.WriteLine(String.Join(" ", result));

        result.Clear();
        foreach (var str in input)
        {
            result.Add(arc.Add(str));
        }
        Console.WriteLine(String.Join(" ", result));

        result.Clear();
        foreach (var str in input)
        {
            result.Add(myList.Add(str));
        }
        Console.WriteLine(String.Join(" ", result));

        List <string> output = new List <string>();

        for (int i = 0; i < counter; i++)
        {
            output.Add(arc.Remove(input[i]));
        }
        Console.WriteLine(String.Join(" ", output));

        output.Clear();
        for (int i = 0; i < counter; i++)
        {
            output.Add(myList.Remove(input[i]));
        }
        Console.WriteLine(String.Join(" ", output));
    }