單鏈表表示多項式筆記:
多項式的項作為節點插入
term *term::insertafter(int c, int e)
2. 多項式的輸出,通過節點類中的運算子過載
//類中定義
friend ostream& operator <<(ostream&, const term&);
ostream& operator <<(ostream& out, const term& x)
}
同理,多項式的類輸出和***輸入***
節點的輸出是為了方便的表示類輸出
istream& operator>>(istream& in, polynomal& x)
}
輸出
ostream& operator << (ostream& out, polynomal& x)
out << endl;
return out;
};
單鏈表 稀疏多項式的表示
稀疏多項式 如p x 1 3x1000 x20000 q x x x50000 r x 1 x 3x1000 x20000 x50000。數學模型 p 1,0 3,1000 1,20000 q 1,1 1,50000 r 1,0 1,1 3,1000 1,20000 1,50000 乙個基礎元素稱為...
用單鏈表表示一元多項式及相加相減相乘運算
標頭檔案 polynomial.h include include using namespace std define true 1 define false 0 define ok 1 define error 0 typedef int status typedef struct term,e...
單鏈表實現多項式相加
include include struct node void destroypoly struct node poly 釋放實現多項式申請的空間 return struct node createnode int coe,int exp 申請空間存放多項式當前項 struct node crea...