Example #1
0
        public Polinom Saberi(Polinom p)
        {
            int longer;

            if (p.GetLength() > GetLength())
            {
                longer = p.GetLength();
            }
            else
            {
                longer = GetLength();
            }

            int[] niz = new int[longer];

            for (int i = 0; i < longer; i++)
            {
                int zbir = 0;
                if (i < GetLength())
                {
                    zbir += GetKoeficijentNaStepenu(i);
                }
                if (i < p.GetLength())
                {
                    zbir += p.GetKoeficijentNaStepenu(i);
                }

                niz[i] = zbir;
            }

            return(new Polinom(niz));
        }
Example #2
0
        static void Main(string[] args)
        {
            int[]   niz1 = { 5, -2, 0, 4 };
            int[]   niz2 = { -3, 4, 1, -4, 8 };
            Polinom p1   = new Polinom(niz1);
            Polinom p2   = new Polinom(niz2);

            Polinom p3 = p1.Saberi(p2);

            System.Console.WriteLine(p3);
        }