程序填空题:List Concatenation
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
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