Example #1
0
        static void Main(string[] args)
        {
            double[]       array     = new double[] { 2, 3, 23, 6, 66, 4, 45, 576, 55, 2, 4, 365, 33, 73, 103, 33, 86, 55, 25, 56, 366, 99, 399, 5, 27, 11, 2, 222, 40, 255, 0, 425 };
            NumberSequence sequence1 = new NumberSequence(array);
            NumberSequence sequence2 = new NumberSequence(array);
            NumberSequence sequence3 = new NumberSequence(array);

            sequence1.SetSortStrategy(new BubbleSort());
            sequence2.SetSortStrategy(new CombSort());
            sequence3.SetSortStrategy(new SequentialSort());

            Console.WriteLine(sequence1);
            sequence1.Sort();
            Console.WriteLine(sequence1);

            OutputSeparationLine();

            Console.WriteLine(sequence2);
            sequence2.Sort();
            Console.WriteLine(sequence2);

            OutputSeparationLine();

            Console.WriteLine(sequence3);
            sequence3.Sort();
            Console.WriteLine(sequence3);
        }
Example #2
0
        static void Main(string[] args)
        {
            double[]       array    = new double[] { 2, 3, 23, 6, 66, 4, 45, 576, 55, 2, 4, 365, 33, 73, 103, 33, 86, 55, 25, 56, 366, 99, 399, 5, 27, 11, 2, 222, 40, 255, 0, 425 };
            NumberSequence sequence = new NumberSequence(array);

            sequence.SetSortStrategy(new BubbleSort());
            sequence.SetSearchStrategy(new LinearSearch());
            int numberToSerachFor = 7;

            Console.WriteLine(sequence.Search(numberToSerachFor));
            sequence.Sort();
            Console.WriteLine(sequence.Search(numberToSerachFor));
        }
        static void Main(string[] args)
        {
            //1. Zadatak

            double[] numbers = new double[] { 7, 4, 6, 14, 9, 1, 3, 2, 0, 12, 5 };

            NumberSequence sequentialSortSequence = new NumberSequence(numbers);

            sequentialSortSequence.SetSortStrategy(new SequentialSort());

            NumberSequence bubbleSortSequence = new NumberSequence(numbers);

            bubbleSortSequence.SetSortStrategy(new BubbleSort());

            NumberSequence combSortSequence = new NumberSequence(numbers);

            combSortSequence.SetSortStrategy(new CombSort());

            sequentialSortSequence.Sort();
            bubbleSortSequence.Sort();
            combSortSequence.Sort();

            Console.WriteLine(sequentialSortSequence.ToString());
            Console.WriteLine(bubbleSortSequence.ToString());
            Console.WriteLine(combSortSequence.ToString());



            //2. Zadatak
            NumberSequence numberSequence = new NumberSequence(numbers);

            numberSequence.SetSearchStrategy(new SeqSearch());

            Console.WriteLine(numberSequence.Search(7));
            Console.WriteLine(numberSequence.Search(14));



            //3. i 4. Zadatak
            SystemDataProvider dataProvider = new SystemDataProvider();

            dataProvider.Attach(new FileLogger("data.txt"));
            dataProvider.Attach(new ConsoleLogger());

            while (true)
            {
                dataProvider.GetCPULoad();
                dataProvider.GetAvailableRAM();
                System.Threading.Thread.Sleep(1000);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            NumberSequence sequence       = new NumberSequence(new double[] { 8, 2, 1, 7, 6, 5, 4, 3, 10, 9 });
            NumberSequence sequencebubble = sequence;
            NumberSequence sequencecomb   = sequence;

            sequence.SetSortStrategy(new SequentialSort());
            sequencebubble.SetSortStrategy(new BubbleSort());
            sequencecomb.SetSortStrategy(new CombSort());
            sequence.Sort();
            Console.WriteLine("Sequential sort:");
            Console.WriteLine(sequence.ToString());
            sequencebubble.Sort();
            Console.WriteLine("Bubble sort:");
            Console.WriteLine(sequencebubble.ToString());
            sequencecomb.Sort();
            Console.WriteLine("Comb sort:");
            Console.WriteLine(sequencecomb.ToString());

            sequence.SetSearchStrategy(new LinearSearch());
            int index = sequence.Search(11);

            if (index != -1)
            {
                Console.WriteLine("Index of given number in the array: " + index);
            }
            else
            {
                Console.WriteLine("There is not given number in the array!");
            }
            int index1 = sequence.Search(10);

            if (index1 != -1)
            {
                Console.WriteLine("Index of given number in the array: " + index1);
            }
            else
            {
                Console.WriteLine("There is not given number in the array!");
            }
        }