コード例 #1
0
ファイル: Program.cs プロジェクト: ZuTa/Algorithms
        static void Main(string[] args)
        {
            Random r = new Random();
            int n = 50;
            int[] array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = r.Next(30);
                Console.Write("{0} ", array[i]);
            }
            Console.WriteLine();

            //array = new int[] { 6, 8, 0, 2, 6, 1 };

            ISolver solver = new BruteForceSolver();
            ISolver dpsolver = new DPSolver();
            ISolver efficientSolver = new EfficientSolver();

            Console.WriteLine(solver.GetLengthOfLongestIncreasingSubSequence(array));
            Console.WriteLine(dpsolver.GetLengthOfLongestIncreasingSubSequence(array));
            Console.WriteLine(efficientSolver.GetLengthOfLongestIncreasingSubSequence(array));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sofiaalidina/Algorithms
        static void Main(string[] args)
        {
            Random r = new Random();
            int    n = 50;

            int[] array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = r.Next(30);
                Console.Write("{0} ", array[i]);
            }
            Console.WriteLine();

            //array = new int[] { 6, 8, 0, 2, 6, 1 };

            ISolver solver          = new BruteForceSolver();
            ISolver dpsolver        = new DPSolver();
            ISolver efficientSolver = new EfficientSolver();

            Console.WriteLine(solver.GetLengthOfLongestIncreasingSubSequence(array));
            Console.WriteLine(dpsolver.GetLengthOfLongestIncreasingSubSequence(array));
            Console.WriteLine(efficientSolver.GetLengthOfLongestIncreasingSubSequence(array));
        }