java中所有的类都继承于_Java中所有的类都是通过直接或间接地继承()类得到的...
閱讀以下應(yīng)用說明、圖和C++程序,將C++程序中(1)~(6)空缺處的語句填寫完整。【說明】以下【C++程序】用于實(shí)現(xiàn)兩個(gè)多項(xiàng)式的乘積運(yùn)算。多項(xiàng)式的每一項(xiàng)由類Item描述,而多項(xiàng)式由類List描述。類List的成員函數(shù)主要有:createList():創(chuàng)建按指數(shù)降序鏈接的多項(xiàng)式鏈表,以表示多項(xiàng)式:reverseList():將多項(xiàng)式鏈表的表元鏈接順序顛倒:multiplyList(ListL1,ListL2)計(jì)算多項(xiàng)式L1和多項(xiàng)式L2的乘積多項(xiàng)式。【C++程序】include <iostream.h>class List;class Item {friend class List;private:double quot ;int exp ;Item *next;Public:Item(double_quot,int_exp){ (1) ;}};class List{private:Item *list;Public:List(){list=NULL:}void reverseList();void multiplyList(List L1,List L2);void createList();};void List::createList(){ Item *p,*U,*pre;int exp;double quot;list = NULL;while (1) {cout << '輸入多項(xiàng)式中的一項(xiàng)(系數(shù)、指數(shù)) :' << endl;cin >> quot >> exp:if ( exp<0 )break ; //指數(shù)小于零,結(jié)束輸入if ( quot=0 )continue;p = list;while ( (2) ) { //查找插入點(diǎn)pre = p;p = p->next;}if ( p != NULL && exp = p->exp ) {p->quot += quot;continue ;}u =(3);if (p == list)list = u;elsepre->next = u;u ->next = p;}}void List::reverseList(){ Item *p, *u;if ( list==NULL )return;p = list ->next;list -> next = NULL;while ( p != NULL) {u = p -> next;p ->next = list;list = p;p = u;}}void List::multiplyList ( List L1, List L2 ){ Item *pL1,*pL2,*u;int k, maxExp;double quot;maxExp =(4):L2.reverseList();list=NULL;for ( k = maxExp;k >= 0;k-- ){pL1 = L1.list;while ( pL1 != NULL && pL1 -> exp > k )pL1 = pL1 ->next;pL2 = L2.1ist;while (pL2 NULL &&(5))pL2 = pL2 -> next;quot = 0.0;while (pL1 != NULL && pL2 != NULL){if(pL1->exp+pL2->exp==k) {(6)pL1 = pL1 -> next;pL2 = pL2 -> next;} else if ( pL1 -> exp + pL2 -> exp > k )pL1 = pL1 -> next;elsepL2 = pL2 -> next;}if ( quot !=0.0 ) {u = new item( quot, k );u -> next = list;list = u;}}reverseList ();L2. reverseList ():}void main(){ List L1,L2,L;
題型:
總結(jié)
以上是生活随笔為你收集整理的java中所有的类都继承于_Java中所有的类都是通过直接或间接地继承()类得到的...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 网络驱动器_删除多余的网络驱动
- 下一篇: java8的rmi_Java中的RMI