Ejemplo n.º 1
0
        private static void Test_DPFunction(int[] outputs)
        {
            Console.WriteLine("FUNKCJA WYKORZYSTUJACA PROGRAMOWANIE DYNAMICZNE");

            int[] result = new int[n];
            for (int i = 0; i < n; ++i)
            {
                try
                {
                    result[i] = SpecialNumbers.SpecialNumbersDP(i);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Incorrect exception: " + e.Message);
                }
            }
            if (Compare_Results(outputs, result))
            {
                Console.WriteLine("Test ZDANY!\n");
            }
            else
            {
                Console.WriteLine("Test OBLANY!\n");
            }
        }
Ejemplo n.º 2
0
        private static void Test_DP2Function(int[] outputs)
        {
            Console.WriteLine("FUNKCJA WYKORZYSTUJACA PROGRAMOWANIE DYNAMICZNE, Z WYMAGANIAMI W TABLICY");

            Console.WriteLine("TEST 1 - specjalne liczby");
            bool[,] req = new bool [9, 9];
            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    req[i, j] = ((i == j) || ((i > j) && (i % 2 != j % 2)));
                }
            }
            int[] result = new int[n];
            for (int i = 0; i < n; ++i)
            {
                try
                {
                    result[i] = SpecialNumbers.SpecialNumbersDP(i, req);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Incorrect exception: " + e.Message);
                }
            }
            if (Compare_Results(outputs, result))
            {
                Console.WriteLine("Test ZDANY!");
            }
            else
            {
                Console.WriteLine("Test OBLANY!");
            }

            Console.WriteLine("TEST 2 - wszystkie cyfry takie same");
            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    req[i, j] = (i == j)? true: false;
                }
            }
            int[] result_t2 = new int[10];
            int[] outp_t2   = new int[10] {
                0, 9, 9, 9, 9, 9, 9, 9, 9, 9
            };
            for (int i = 0; i < 10; ++i)
            {
                try
                {
                    result_t2[i] = SpecialNumbers.SpecialNumbersDP(i, req);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Incorrect exception: " + e.Message);
                }
            }
            if (Compare_Results(outp_t2, result_t2))
            {
                Console.WriteLine("Test ZDANY!");
            }
            else
            {
                Console.WriteLine("Test OBLANY!");
            }

            Console.WriteLine("TEST 3 - tylko jednocyfrowe");
            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    req[i, j] = false;
                }
            }
            int[] result_t3 = new int[10];
            int[] outp_t3   = new int[10] {
                0, 9, 0, 0, 0, 0, 0, 0, 0, 0
            };
            for (int i = 0; i < 10; ++i)
            {
                try
                {
                    result_t3[i] = SpecialNumbers.SpecialNumbersDP(i, req);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Incorrect exception: " + e.Message);
                }
            }
            if (Compare_Results(outp_t3, result_t3))
            {
                Console.WriteLine("Test ZDANY!");
            }
            else
            {
                Console.WriteLine("Test OBLANY!");
            }

            Console.WriteLine("TEST 4 - kolejna cyfra mniejsza od poprzedniej");
            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    req[i, j] = i > j ? true: false;
                }
            }
            int[] result_t4 = new int[20];
            int[] outp_t4   = new int[20] {
                0, 9, 36, 84, 126, 126, 84, 36, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };
            for (int i = 0; i < 20; ++i)
            {
                try
                {
                    result_t4[i] = SpecialNumbers.SpecialNumbersDP(i, req);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Incorrect exception: " + e.Message);
                }
            }
            if (Compare_Results(outp_t4, result_t4))
            {
                Console.WriteLine("Test ZDANY!");
            }
            else
            {
                Console.WriteLine("Test OBLANY!");
            }
        }