【说明】本程序将两个从小到大的有序链表合成一个新的从小到大的有序链表。链表的每一项由

题型:问答题

问题:

【说明】本程序将两个从小到大的有序链表合成一个新的从小到大的有序链表。链表的每一项由类Node描述,而链表由类List描述。类List的成员函数有以下几个。
①createList():创建从小到大的有序链表。
②multiplyList(List L1,List L2):将链表L1和链表L2合并。
③print();打印链表。
# include <iostream.h>
class List;
class Node
friend class List;
public:
Node(int data)
(1) ;
private:
int data;
Node *next;
;
class List
public:
List( ) list = NULL;
void multiplyList(List L1, List L2);
void createList( );
void print( );
private:
Node *list;
;
void List::createList( )
Node *p, *u, *pm;
int data;
list = NULL;
while (1)
cout<<"输入链表的一项: (小于零,结束链表)"<<end1;
cin >> data;
if(data<0)break;//小于零,结束输入
p = list;
while (p != NULL && data > p->data) //查找插入点
pre = p;
p = p->next;

u= (2) :
if(p==list)
list = u;
else
pre->next = u;
(3) :void List::multiplyList (List L1, List L2)
Node *pL1, *pL2, *pL, *u;
list = NULL;
pL1 = L1.list;
pL2 = L2.1ist;
while (pL1 != NULL && pL2!= NULL)

if (pL1->data < pL2->data)
u = new Node (pL1->data);
pL1 = pL1 ->next;

else
u = new Node (pL2->data));
pL2 = pL2->next;

if (list==NULL)
list= (4) ;
else
pL->next = u;
pL =u;


pL1 = (pL1 != NULL) pL1:pL2;
while (pL1 != NULL)
u = (5) ;
pL1 = pL1->next;
if (list==NULL)
list=pL=u;
else
pL->next = u;
pL = u;

void List::print( )
Node *p;
p = list;
while (p != NULL)
cout << p->data << "\t";
p = p->next;

cout << end1;void main ( )
List L1, L2, L;
cout << "创建第一个链表\n"; L1.createList ( );
cout << "创建第二个链表\n"; L2.createList ( );
L1.print ( ); L2.print ( );
L.multiplyList (L1, L2);
L.print ( );

考点:计算机软件水平考试中级软件设计师中级软件设计师下午试题
题型:问答题

小题1:In the Lifestyle section, you may Not find ____________.

A.journals of adventure

B.well-taken photographs

C.stories of Leonard Maltin

D.opinions on restaurants小题2:Which of the following is TRUE about Campus Link?

A.It offers readers its best-made bread and butter.

B.It welcomes research developments and breakthroughs.

C.It helps you to recognize your schoolmates and teachers.

D.It is a source of inspiration for the community.小题3:The poster aims to __________.

A.made known the rights of Campus Link

B.introduce the way to send submissions

C.share views and articles among teachers

D.encourage contributions for the issue

题型:问答题

已知一个正方体的棱长是5cm,再做一个正方体,使它的体积是原来正方体体积的2倍,求所做正方体的棱长(结果精确到0.1cm)。

题型:问答题

如果两圆相切,圆心距为7cm,一个圆的半径为4cm,则另一个圆的半径为(  )

A.3cm

B.11cm

C.8cm

D.3cm或11cm

题型:问答题

成人无尿是指24h尿量少于()

A.100ml

B.200ml

C.300ml

D.400ml

E.500ml

题型:问答题

80X86CPU可以访问的I/O地址空间共有()

A.256

B.1K

C.64K

D.128K

更多题库