本文整理汇总了C++中Poly::insertPoly方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::insertPoly方法的具体用法?C++ Poly::insertPoly怎么用?C++ Poly::insertPoly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::insertPoly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Poly Poly::operator/(const Poly& orig)const //Division Overload
{
Poly quotient; //list to store the quotient of LHS/RHS
Poly dividend = *this; //Copy LHS dividend to new list called dividend
while(true)
{
Poly qTerm;
//this operation returns an empty list if dividend is null
//the dividend is decremented by an iteration of the quotient (qterm) * divisor
//eventually the dividend will be less than the divisor upon which it will return quotient
//further each iteration of qterm is accumulated in the quotient
//also note when dividend is less than the divisor, this means dividend is now the remainder
if((dividend.Head ==NULL)||(orig.Head->exponent > dividend.Head->exponent))
{
bool loop = true;
for(Node *cur = quotient.Head;(quotient.Head!=NULL) && ((cur!=quotient.Head) || (loop)); cur = cur->next)
{
loop = false;
cur->coefficient = -cur->coefficient;
}
return quotient;
}
qTerm.insertPoly(-(dividend.Head->coefficient/orig.Head->coefficient), dividend.Head->exponent-orig.Head->exponent);
quotient = quotient + qTerm; //quotient is accumulated
dividend = (dividend + (qTerm * orig)); //dividend is decremented with every successfull division iteration
}
}