main.cpp

来自「数据结构的一些简单算法」· C++ 代码 · 共 45 行

CPP
45
字号
//===========================================================================
//                               main.cpp
//                    xuwenshuan@robort.nankai.edu.cn
//===========================================================================

#include "list.h"
void Input(list<moNode> &mulist)
{
	//construct new list
	float TemCoef;
	int   TemExp ;
	while(cin>>TemCoef>>TemExp)
	{
		if(TemCoef == 0) break;
		moNode* new_moNode;
		new_moNode = new moNode(TemCoef,TemExp);
		int position; 
		bool SamExp  ;
		SamExp = mulist.ser_position(*new_moNode,position);
		if(SamExp)
		{
			cout<< mulist.add(position,*new_moNode) <<endl ;
		}
		else
		{
			cout<< mulist.insert(position,*new_moNode) << endl ;
		}
	}
	cout << mulist.output() << endl ;
}
void main ()
{
	moNode* new_moNode;
	new_moNode = new moNode;
	list<moNode> mulistA(*new_moNode);
	Input(mulistA);
	new_moNode = new moNode;
	list<moNode> mulistB(*new_moNode);
	Input(mulistB);

	cout << mulistA.add (mulistA,mulistB) << endl ;
	cout << mulistA.output();

	cout << mulistA.mul (mulistA,mulistB) << endl ;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?