13411 - Do something to the linked-list   

Description

In this partial-judge problem, you are asked to implement 2 functions:

Node* insert_sorted_list(Node* head, int val);
Node* merge_sorted_list(Node** heads);

 

For insert_sorted_list , you are given the head of a linked list and a integer val .You have to create a node with value val and insert it into the linked list so it can remain sorted.

The insertion operation will be like:

For merge_sorted_list , you have to merge 2 linked-list stored in the pointer array heads and remain the merged list sorted.

 

Input

There will be 2 lines of integers(1<= val <=100000000), which are the values of the 2 linked-lists.

The input stops when read in '-1' ('-1' is not a part of the 2 linked-lists).

 

Output

The values of the merged linked-list.

The values are separated by a whitespace and the output is also ended with a whitespace.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13411.c

Partial Judge Header

13411.h

Tags




Discuss