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

程序填空题:List Concatenation

Luz4年前 (2021-05-10)题库2068
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→4→5→6→1→2→3.

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 = L2;
if ( !L2 ) return L1;
while ( Tmp->Next )
@@[Tmp = Tmp->Next](3);
@@[Tmp->Next = L1](3);
return @@[L2](3);
}
```






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

第2空:Tmp->Next = L1

第3空:L2

发表评论

访客

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