2142 - IP_2020_YOU_LAB6 Scoreboard

Time

2020/10/27 15:30:00 2020/10/27 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12943 Implement Stack Using Linked List
12944 Traversal Linked List in Reverse Order

12943 - Implement Stack Using Linked List   

Description

Please use the provided two files, main.c and function.h, to implement a stack. Includes following functions:

  1. Push: insert an element into a stack.
  2. Pop: remove the last element from a stack.
  3. Peek the last element: print the last element’s value inside a stack.
  4. Check if it is empty: Check if a stack is empty.

Note:

  1. A Stack data structure shold follow LIFO(last in first out) rule.
  2. Print nothing if there is no elements.

Go download function.c, and only need to submit function.c.

Input

Legal commands:

  1. “push” with an integer N in a new line: Insert an element which value is N into the stack.
  2. “pop”: remove the last element inside the stack and return its pointer.
  3. “top”: print the last element inside the stack.
  4. “isempty?”: Check if the stack is empty.

Output

No need to handle output. Please use function.c above.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12943.c

Partial Judge Header

12943.h

Tags




Discuss




12944 - Traversal Linked List in Reverse Order   

Description

Please use the provided two files, main.c and function.h, to implement methods:

  1. Insert nodes to a list.
  2. Traversal a linked list in reverse order.

Go download function.c, and only need to submit function.c.

Input

n

N1 N2 N3 N4 … Nn

Note:

  1. n represents how many numbers would be provided.
  2. 32,767 >= n >= 0.
  3. 32,767 >= N(n) >= -32768.

Output

Output should follow below format:

Print: N1 N2 N3 N4 … Nn

Reverse: Nn Nn-1 Nn-2 … N1

Note that:

  1. Need to have a return value('\n') at the end of your output.
  2. Need a ‘Space’ between ‘:’ and N1.
  3. Need a ‘Space’ between any two numbers.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12944.c

Partial Judge Header

12944.h

Tags




Discuss