📄 main.cpp
字号:
//===========================================================================
//Project Descriprion
//===========================================================================
//Project name : Multinomial Operation
//Author : Aries
//Description : rt
//Creat Date : 2005/3/12
//Version : Ver#1.0 by Aries at 2005/3/12 0:30
//===========================================================================
//===========================================================================
//Thinking before coding...
//===========================================================================
//Multinomial ax(n) + bx(n-1) + ...
//Input compositor hoho~
//Add.. add one list node by node to another
//Sub.. just like add ...
//Mul.. 1 mul nodes of the list with list --> n lists
// 2 n list add
//===========================================================================
//===========================================================================
// main.cpp
//===========================================================================
#include "list.h"
void Input(list<moNode> &mulist)
//construct new list
{
float TemCoef;
int TemExp ;
//Introduction of the form
cout << "[ Input the node of the Multinomial ]" << endl
<< "[ Forms by ] " << endl
<< " 3 2" << endl
<< " 1 9" << endl
<< "-1 -4" << endl
<< "..." << endl;
cout << "[ End by : 0 0 ]" << endl;
//input the list
while( cin >>TemCoef>>TemExp )
{
//list input ended by 0
if(TemCoef == 0) break;
//constuct one node using inputed data and link it to the list
moNode* new_moNode;
new_moNode = new moNode(TemCoef,TemExp);
int position;
bool SamExp;
// bool var SamExp , records the imformation
// to decide whether add the new node to a certain place
// where the exp of the node equal to the new node or insert it
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 << "[ Input the node of the Multinomial ]" << endl ;
}
cout << mulist.output() << endl ;//output the inputed list
}
void main ()
{
moNode* new_moNode;
//construct mulistA
new_moNode = new moNode;
list<moNode> mulistA(*new_moNode);
Input(mulistA);
//construct mulistB
new_moNode = new moNode;
list<moNode> mulistB(*new_moNode);
Input(mulistB);
//control the operator in + or *
char op = NULL;
while( op != '+' && op != '*' )
{
cout << "Choose the operator ( + or * ) : " << endl ;
cin >> op ;
}
if( op == '+' )//case +
{
cout << mulistA.add (mulistA,mulistB) << endl ;
cout << "[ + The result is + ]" << endl ;
cout << mulistA.output() << endl ;
}
else //case *
{
cout << mulistA.mul (mulistA,mulistB) << endl ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -