12118 - CS_2018_FINAL-2   

Description

Given a linked list, you have to reverse it and output the result.

You have to implement four function:

1. Node* Create_List(Node*, int);

This function is used to create the linked list according to the input.

2. Node* Reverse_List(Node*);

This function is used to reverse the given linked list.

3. void Print_List(Node*);

This function is used to print out the key value in the linked list.

4. void Free_List(Node*);

This function is used to free the memory space.

Input

The first line contains one integer n, representing the number of nodes in the linked list.

The next lines contains n integers, each integer represents a node in the linked list.

It is guaranteed that :

  • 1 ≤ n ≤ 10
  • 0 ≤ ai ≤ 100

Output

You need to output the reversed linked lists.

Each key value is separated by "->".

You need to print '\n' in the end

Sample Input  Download

Sample Output  Download

Partial Judge Code

12118.c

Partial Judge Header

12118.h

Tags




Discuss