コード例 #1
0
        private static void TestFactorial()
        {
            Console.WriteLine(1 == Factorial.CalculateRecursive(0));
            Console.WriteLine(1 == Factorial.CalculateRecursive(1));
            Console.WriteLine(2 == Factorial.CalculateRecursive(2));
            Console.WriteLine(6 == Factorial.CalculateRecursive(3));

            Console.WriteLine(1 == Factorial.Calculate(0));
            Console.WriteLine(1 == Factorial.Calculate(1));
            Console.WriteLine(2 == Factorial.Calculate(2));
            Console.WriteLine(6 == Factorial.Calculate(3));
        }
コード例 #2
0
        private static async Task <bool> Execute(char choice)
        {
            switch (choice)
            {
            case '1':
            {
                Factorial.Compute(GetInput());
                return(true);
            }

            case '2':
            {
                await Fibonacci.Compute(GetInput());

                return(true);
            }

            case '3':
            {
                Console.Write($"{Environment.NewLine}Enter source text: ");
                var sourceText = Console.ReadLine();
                Console.Write($"{Environment.NewLine}Enter search text: ");
                var searchText = Console.ReadLine();
                PatternMatching.Search(sourceText, searchText);
                return(true);
            }

            case '4':
            {
                var demo = new Demo {
                    No = 10
                };
                demo.Print();
                var demo2 = new Demo();
                demo2.Print();
                return(true);
            }

            case '5':
            {
                Numeric.FindPairs(new int[] { -7, 4, -3, 2, 2, -8, -2, 3, 3, 7, -2, 3, -2 });
                return(true);
            }

            default:
                return(false);
            }
        }