作业帮 > 综合 > 作业

二元多项式计算能够按照指数和升序排列建立并输出多项式;能够完成两个多项式的加法,减法,乘法,并将结果存储于一个新的多项式

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/10 09:26:08
二元多项式计算
能够按照指数和升序排列建立并输出多项式;能够完成两个多项式的加法,减法,乘法,并将结果存储于一个新的多项式中.
#include #include #include #include using namespace std; class _Item:public pair < int,int > { public:_Item():pair < int,int > (int(),int()){} _Item(int a,int b):pair < int,int > (a,b){} _Item(const _Item &rhs):pair < int,int > (rhs.first,rhs.second){} inline bool operator < (const _Item &other)const { return second < other.second; } inline bool operator==(const _Item &other)const { return second==other.second; } inline bool operator > (const _Item &other)const { return second > other.second; } inline void operator+=(const _Item &other) { first+=other.first; } inline void operator-=(const _Item &other) { first-=other.first; } inline void operator*=(const _Item &other) { first*=other.first; second+=other.second; } void operator=(const _Item &other) { first=other.first; second=other.second; } friend istream &operator>>(istream &is,_Item &it) { is>>it.first>>it.second; return is; } friend ostream &operato