11430 - Implement a list 1 (erase and insert)   

Description

Warning: You are not allowed to use:

1. any static variables

2. any variables which is not inside a function

3. malloc and free

由於實際的code有做其他檢查,因此為了讓各位方便閱讀,請參考簡化版本的function.hmain.cpp(請點連結)

 

You are required to implement a list.

You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")

Input

The input consist of a number of operations. Each operations (erase, insert and S) are separated by a newline character ('\n').

Operation insert: following by a non-negative integer (insert position) and a non-negative integer (insert value, 0<=insert value<65535). Insert a node at insert position with insert value.

Operation erase: following by a non-negative integer (erase position). Erase a node at erase position.

Operation show: print the value of all nodes in the list. Print a whitespace character (' ') after printing the value of nodes. If the list is empty, do not print anything.

Output

如果不知道operator<<如何實作,可以看 main.cpp

Implement List (constructor, destructor, erase and insert), operator<<(std::ostream &,const List &lst).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11430.cpp

Partial Judge Header

11430.h

Tags




Discuss