-->
当前位置:首页 > 题库 > 正文内容

程序填空题:Concatenation of lists

Luz4年前 (2021-05-10)题库2395
Concatenation of lists is an operation where the elements of one list are added at the end of another list. For example, if we have a linked list `L1`→1→2→3 and another one `L2`→4→5→6. The function `ListConcat` is to return the head pointer of the list L→1→2→3→4→5→6.

The list structure is defined as the following:

```
typedef struct Node *PtrToNode;
struct Node{
int Data;
PtrToNode Next;
};
typedef PtrToNode List;
```

Please fill in the blanks.

```
List ListConcat( List L1, List L2 )
{
List Tmp = L1;
if ( !L1 ) return L2;
while ( Tmp->Next )
@@[Tmp = Tmp->Next](3);
@@[Tmp->Next = L2](3);
return @@[L1](3);
}
```






答案:
第1空:Tmp = Tmp->Next

第2空:Tmp->Next = L2

第3空:L1

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。