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


C++ Polynomial::insert方法代码示例

本文整理汇总了C++中Polynomial::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::insert方法的具体用法?C++ Polynomial::insert怎么用?C++ Polynomial::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polynomial的用法示例。


在下文中一共展示了Polynomial::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readpoly

//Read a polynomial from an inputstream
void Helper::readpoly(std::ifstream& ifs, Polynomial& poly)
{
  char c;
  while(ifs>>c)
  {
    int iCoefficient = 0, iExponent = 0;
    ifs>>iCoefficient>>c>>iExponent;
    ifs>>c;
        
    if(iExponent == 0 && iCoefficient == 0)
      return;
    else
      poly.insert(iCoefficient, iExponent);
  }

}
开发者ID:mycstdlib,项目名称:school-work,代码行数:17,代码来源:helper.cpp

示例2:

	/* Multiplication: multiplies two polynomials 
	   For each term in second polynomial, copies
	   the first polynomial and multiplies each of 
	   its terms by the second's term and inserts
	   the results into the output polynomial.
	*/
	Polynomial operator*(const Polynomial p){
		 
		Polynomial output;
		Term* currentA = head;

		/* for each term in A */
		while (currentA->next)
		{
			/* for each term in B, multiply against
			   A's term and insert into output*/
			Term* currentB = p.head;
			while (currentB->next)
			{
				output.insert(*currentA->next * *currentB->next);
				currentB = currentB->next;
			}
			
			currentA = currentA->next;
		}

		return output;
	}
开发者ID:CSAlexWhite,项目名称:Assignment5_Polynomial,代码行数:28,代码来源:Polynomial.cpp

示例3: main

int main()
{
    ifstream myFile("dataPoly.txt");
	string currC;
	string currE;
	string currL;
	double currCoeff;
	int currExpon;
	int x = 0,y,z,pNum;
	string numPoly;

   	Polynomial* polyArray[12];

	for(int i = 0; i < 12; i++)
	{
		Polynomial* polyList = new Polynomial;
		polyArray[i] = polyList;
	}
///////////////////////////////////////////////////////////////////////////////////////////
	if (myFile.is_open())
	{
		myFile >> numPoly;
		pNum = atoi(numPoly.c_str());

		for(int i = 0; i < pNum;i++)
		{
			Polynomial* polyList = polyArray[i];

			myFile >> currC;
			myFile >> currE;
			currCoeff = atof(currC.c_str());
			currExpon = atoi(currE.c_str());
			polyList->insert(currCoeff,currExpon,polyArray[10]);

			while(currExpon != 0)
			{
				myFile >> currC;
				myFile >> currE;
				currCoeff = atof(currC.c_str());
				currExpon = atoi(currE.c_str());
				polyList->insert(currCoeff,currExpon,polyArray[10]);
			}

			polyArray[x] = polyList;
			x++;
		}
/////////////////////////////////////////////////////////////////////////////////////////////////////
		while(currL.compare("Q") !=  0 && myFile >> currL)
		{
			if (currL.compare("R") == 0)
			{
				myFile >> currL;
				int x = atoi(currL.c_str()) - 1;
				polyArray[10]->remove(polyArray[x]);
				Polynomial* polyList = polyArray[x];
				myFile >> currC;
				myFile >> currE;
				currCoeff = atof(currC.c_str());
				currExpon = atoi(currE.c_str());
				polyList->insert(currCoeff,currExpon,polyArray[10]);

				while(currExpon != 0)
				{
					myFile >> currC;
					myFile >> currE;
					currCoeff = atof(currC.c_str());
					currExpon = atoi(currE.c_str());
					polyList->insert(currCoeff,currExpon,polyArray[10]);
				}
			}
			else if(currL.compare("A") == 0)
开发者ID:haydenx83,项目名称:School,代码行数:71,代码来源:main.cpp


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