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