12846 - Reverse Linked List ver 2   

Description

Given several operations, push xpopprintreverse, create a linked list dynamicly.

  • push x: Add one Node (with data = x) at the front of linked list.
  • pop: Delete the Node at the front of linked list.
  • reverse: reverse the current linked list
  • print: output the linked list in given format.

You have to implement 3 functions:

1. void Push(Node** ptr_head,int x)
2. void Pop(Node** ptr_head)
3. void Reverse_List(Node** ptr_head)

Note: Modify the Node* head by Node** ptr_head

Input

There’re operations on several lines.
All operations are one of push xpopprintreverse.
It’s guaranteed that:

  • Number of operations is less than 5,000,000
  • Integer x is in [1000,1000]
  • The maximum length of linked list is less than 10,000.

Output

Output the linked list for every print.

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

12846.c

Partial Judge Header

12846.h

Tags




Discuss