微软等数据结构与算法面试100题 第七题(二)

2014-11-24 10:52:24 · 作者: · 浏览: 1
j = new struct linkNode();
linkNode *k = new struct linkNode();
linkNode *l = new struct linkNode();

head2->nextLinkNode = i;
head2->value = 10;
i->nextLinkNode = j;
i->value = 11;
j->nextLinkNode = head1;
j->value = 12;

linkNode *head3 = new struct linkNode();
linkNode *m = new struct linkNode();
linkNode *n = new struct linkNode();
linkNode *o = new struct linkNode();
linkNode *p = new struct linkNode();

head3->nextLinkNode = m;
head3->value =21;
m->nextLinkNode = n;
m->value = 22;
n->nextLinkNode = o;
n->value = 23;
o->nextLinkNode = p;
o->value = 24;
p->nextLinkNode = n;
p->value = 25;

linkNode *head4 = new struct linkNode();
head4 ->nextLinkNode = o;
head4 ->value = 31;

temp = head1;
int maxNum =20;
int tempindex = 0;
while(NULL != temp&&tempindex < maxNum)
{
tempindex = tempindex + 1;
cout<value<<" ";
temp = temp->nextLinkNode;
}
cout< temp = head2; maxNum =20;tempindex = 0;
while(NULL != temp&&tempindex < maxNum)
{
tempindex = tempindex + 1;
cout<value<<" ";
temp = temp->nextLinkNode;
}
cout< temp = head3; maxNum =20;tempindex = 0;
while(NULL != temp&&tempindex < maxNum)
{
tempindex = tempindex + 1;
cout<value<<" ";
temp = temp->nextLinkNode;
}
cout< temp = head4; maxNum =20;tempindex = 0;
while(NULL != temp&&tempindex < maxNum)
{
tempindex = tempindex + 1;
cout<value<<" ";
temp = temp->nextLinkNode;
}
cout< #pragma endregion


check2LinkList(head1,head2);
check2LinkList(head1,head3);
check2LinkList(head3,head4);
return 0;
}