当前位置: 首页>>代码示例>>C++>>正文


C++ Poly::insertPoly方法代码示例

本文整理汇总了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
	}
}
开发者ID:hailemariamag,项目名称:CCPP,代码行数:27,代码来源:PolytermsP.cpp


注:本文中的Poly::insertPoly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。