예제 #1
0
        ///<summary>
        ///求幂
        ///</summary>
        public static Dovahkiin Dpow(Dovahkiin d, double n)
        {
            double x = Math.Pow(d.shibu * d.shibu + d.xubu * d.xubu, n / 2); //难以言说的操作
            double y = Math.Pow(d.shibu * d.shibu + d.xubu * d.xubu, 1 / 2); //求模
            double a = Math.Asin(d.xubu / y);                                //求角度
            double b = Math.Cos(n * a);
            double c = Math.Sin(n * a);

            return(new Dovahkiin(x * b, x * c));//用x(cosθ+sinθ)表示结果
        }
예제 #2
0
        static void Main()
        {
            //读入数据

            Console.WriteLine("please enter a real number:");

            int a = Console.Read();

            Console.WriteLine("please enter a imaginary number:");

            int b = Console.Read();

            Console.WriteLine("please enter a real number:");

            int c = Console.Read();

            Console.WriteLine("please enter a imaginary number:");

            int d = Console.Read();

            //数值计算

            Dovahkiin num1 = new Dovahkiin(a, b);

            Dovahkiin num2 = new Dovahkiin(c, d);

            Dovahkiin sum = num1 + num2;

            Dovahkiin sub = num1 - num2;

            Dovahkiin multiplication = num1 * num2;

            Dovahkiin division = num1 / num2;

            //输出结果

            Console.WriteLine("第一个复数:  {0}", num1);

            Console.WriteLine("第二个复数: {0}", num2);

            Console.WriteLine("复数和: {0}", sum);

            Console.WriteLine("复数差: {0}", sub);

            Console.WriteLine("复数积: {0}", multiplication);

            Console.WriteLine("复数商: {0}", division);

            Console.WriteLine("please enter a real number:");

            int g = Console.Read();

            Console.WriteLine("please enter a imaginary number:");

            int e = Console.Read();

            Console.WriteLine("please enter a  number as the power:");

            int f = Console.Read();

            //乘方运算

            Dovahkiin num3 = new Dovahkiin(g, e);

            for (int i = 1; i <= f; i++)

            {
                Dovahkiin power = num3 * num3;



                Console.WriteLine("乘方是: {0}", power);
            }
        }