C#中的多项式除法 [英] Division of Polynomials in C#

查看:103
本文介绍了C#中的多项式除法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class Polinom
    {
        int ID;
        private double[] a;
        private int n;
        static int count;

        public Polinom(int _n, double[] b = null)
        {
            if (_n < 0) _n = 0;
            n = _n + 1;
            a = new double[n];
            if (b != null)
                for (int i = 0; i < n; i++) a[i] = b[i];

            count++;
            ID = count;
            Console.WriteLine("Конструктор {0}", ID);
        }

        public Polinom(double[] b = null)
        {
            
            if (b.GetLength(0) < 0) 
                n = 0;
            n = b.GetLength(0) +1;
            a = new double[n];
            if (b != null)
                for (int i = 0; i < n; i++) a[i] = b[i];

            count++;
            ID = count;
            Console.WriteLine("Конструктор {0}", ID);
        }

        ~Polinom()
        {
            Console.WriteLine("Деструктор {0}", ID);
        }

        public double this[int x]
        {
            get
            {
                return a[x];
            }

            set
            {
                a[x] = value;
            }
        }

        public int N
        {
            get
            {
                return n - 1;
            }
        }

        public void Reduce()
        {
            int r = 0;

            for (int i = n - 1; i >= 0; i--)
            {
                if (a[i] != 0)
                {
                    break;
                }

                else
                {
                    r++;
                }
            }

            double[] tt = new double[n - r];
            for (int i = 0; i < n - r; i++)
                tt[i] = this.a[i];

            a = tt;
            n -= r;
        }







 public static Polinom operator / (Polinom first, Polinom second)
        {
//????
}


我正在阅读算法,如何将一种策略划分为另一种.但是我还不知道如何实现它.请帮助我.


I was reading algorithm how to divide one polinomial on other. But I haven''t any idea how to realize it. Help me, please.

推荐答案

您要么
  • 不了解该算法.
  • C#语言的了解不足以实现该算法.
You either
  • Don''t understand the algorithm.
  • Are not enough proficient in C# language in order to implement it.


这篇关于C#中的多项式除法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆