第1个回答 2014-10-28
struct node
{
int nodeValue;
node *pNext;
};
int add(node *pNode)
{
int total = 0;
//遍历 链表 pNode 将每个节点的 nodeValue叠加到 total;直到 pNext为空
while(pNode != null)
{
total += pNode->nodeValue;
pNode = pNode->pNext;
}
return total;
}
void linkb2a(node *a,node *b)
{
//遍历 链表a 找到a的尾节点(尾节点的 pNext为空)
while(a->pNext != null)
a = a->pNext;
//将 a的尾节点的 pNext 指向 b 的首节点
a->pNext = b;
}
////
测试代码比较麻烦 就不写了本回答被网友采纳