List Read(); /* 细节在此不表 */ void Print( List L ); /* 细节在此不表;空链表将输出NULL */
List Merge( List L1, List L2 );
int main() { List L1, L2, L; L1 = Read(); L2 = Read(); L = Merge(L1, L2); Print(L); Print(L1); Print(L2); return 0; }
/* 你的代码将被嵌在这里 */
List Read() { int n; scanf("%d", &n); List L = (List)malloc(sizeof(PtrToNode)); L->Next = NULL; if ( n ) { List r = L; for ( int i=0; i<n; i++ ) { List p = (List)malloc(sizeof(struct Node)); scanf("%d", &(p->Data)); r->Next = p; r = p; } r->Next = NULL; } return L; }
void Print( List L ) { List p = L; if ( p->Next ) { while ( p->Next ) { p = p->Next; printf("%d ", p->Data); } } else { printf("NULL "); } }