Beispiel #1
0
        static void Main(string[] args)
        {
            List             myList = new List();
            StackRepetitions MyStackOfRepetitions = new StackRepetitions();
            StackUnique      MyStackOfUniques     = new StackUnique();
            Random           randomNumber         = new Random();


            for (int i = 0; i < 10; i++)
            {
                myList.InsertIntoBeginning(randomNumber.Next(1, 20));
            }

            Console.WriteLine("----------------------------");
            Console.WriteLine("My list: ");
            myList.ShowList();
            Console.ReadKey();


            myList.FindDuplicateNumbers(MyStackOfRepetitions, MyStackOfUniques);

            Console.WriteLine("\n----------------------------");
            Console.WriteLine("My stack of repetitions: ");
            MyStackOfRepetitions.ShowStack();
            Console.ReadKey();

            Console.WriteLine("----------------------------");
            Console.WriteLine("My stack of unique values: ");
            MyStackOfUniques.ShowStack();
            Console.ReadKey();
        }
Beispiel #2
0
        public void FindDuplicateNumbers(StackRepetitions stackRepetitions, StackUnique stackUnique)
        {
            Aux = First;
            while (Aux != null)
            {
                stackUnique.InsertIntoStack(Aux.value);
                TestValue = Aux.next;

                while (TestValue != null)
                {
                    if (Aux.value == TestValue.value)
                    {
                        stackRepetitions.InsertIntoStack(Aux.value);
                    }
                    TestValue = TestValue.next;
                }
                Aux = Aux.next;
            }
        }