Пример #1
0
polynomial operator *(const polynomial &p1, const polynomial &p2)
{
    polynomial p3;
    Iterator<polyterm> poly1, poly2;
    Node<polyterm> newTerm;


    poly1=p1.Begin();
    while(poly1.GetNode()!=NULL)
    {

        poly2 = p2.Begin();
        while(poly2.GetNode()!=NULL)
        {
            newTerm = *poly1.GetNode()* *poly2.GetNode();

            p3.InsertSorted(new Node<polyterm>(newTerm));


            poly2.Next();
        }
        poly1.Next();
    }
    return p3;




}
Пример #2
0
polynomial operator -(const polynomial &p1)
{
    polynomial negated;

    Iterator<polyterm> P = p1.Begin();

    while(P.GetNode() != NULL)
    {
        Node<polyterm> negTerm = -(*P.GetNode());
        negated.Append(negTerm.Copy());
        P.Next();
    }

    return negated;
}