コード例 #1
0
ファイル: Program.cs プロジェクト: hibace/HomeworksCSharp
 static void Main(string[] args)
 {
     Polynomial polA = new Polynomial(new double[] { 7, 2, 8, -7 });
     Polynomial polB = new Polynomial(new double[] { 4, 0, 17 });
     Console.WriteLine("Полиномы:");
     Console.Write("polA = ");
     polA.Print();
     Console.Write("polB = ");
     polB.Print();
     Console.WriteLine("\nОперации над двумя полиномами:");
     Console.Write("polA + polB = ");
     (polA + polB).Print();
     Console.Write("polA - polB = ");
     (polA - polB).Print();
     Console.Write("polA * polB = ");
     (polA * polB).Print();
     Console.WriteLine("\nОперации над полиномом и числом:");
     Console.Write("polA + 10 = ");
     (polA + 10).Print();
     Console.Write("polA - 10 = ");
     (polA - 10).Print();
     Console.Write("polA * 10 = ");
     (polA * 10).Print();
     Console.Write("polA / 10 = ");
     (polA / 10).Print();
     Console.WriteLine("\nLagrange Polynomial:");
     LagrangePolynomial lpol = new LagrangePolynomial(new Tuple<double, double>[] { new Tuple<double, double>(-1.5, -14.1014), new Tuple<double, double>(-0.75, -0.931596), new Tuple<double, double>(0, 0), new Tuple<double, double>(0.75, 0.931596), new Tuple<double, double>(1.5, 14.1014) });
     lpol.PrintLP();
     Console.WriteLine("\nCalculate:");
     Console.WriteLine(lpol.Calc(2));
     Console.ReadLine();
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: Ran1s/HomeworksCSharp
        static void Main(string[] args)
        {
            Polynomial p1 = new Polynomial(new double[] { 1, 2, 3, 4 });
            Polynomial p2 = new Polynomial(new double[] { 1, 2 });
            Console.WriteLine(p1);
            Console.WriteLine(p2);
            Console.WriteLine(p1 + p2);
            Console.WriteLine(p1 - p2);
            Console.WriteLine(p1 * p2);
            Console.WriteLine(p1 + 100);
            Console.WriteLine(p1 - 100);
            Console.WriteLine(p1 * 100);
            Console.WriteLine(p1 / 100);

            LagrangePolynomial lp1 = new LagrangePolynomial(new Tuple<double, double>[] { new Tuple<double, double>(-1.5, -14.1014), new Tuple<double, double>(-0.75, -0.931596), new Tuple<double, double>(0, 0), new Tuple<double, double>(0.75, 0.931596), new Tuple<double, double>(1.5, 14.1014) });

            Console.WriteLine(lp1);
        }