西西里2286. Stack Implementation

这么过分一定要发CSDN!

题目

  1. Stack Implementation
    Constraints
    Time Limit: 1 secs, Memory Limit: 256 MB , Framework Judge

Description
Implement the following Stack:

typedef int Stack_entry;

class Stack {
public:
// Standard Stack methods
Stack();
bool empty() const;
/* Returns true if the stack is empty, otherwise, returns false.
/
int size() const;
/
Returns the number of elements in the stack.
*/
void push(const Stack_entry &item);
/*item is pushed into the stack and it becomes the new top element.
*/
void pop();
/*The top item is removed if the stack is not empty.
Otherwise, nothing happens.
*/

Stack_entry & top() const;
/* The top element is returned by item if the stack is not empty,
and the stack remains unchanged.
Nothing happens if the stack is empty.
*/
// Safety features
~Stack();
Stack(const Stack &original);
void operator =(const Stack &original);
};

typedef Stack MyStack;

//or if your are using templates

typedef Stack MyStack;

Hint
Submit your implementations only.

Problem Source
ADTs: Implementations and Applications

AC的答案

这题目其实是很基础的stack的实现,不过这个题目的要求怎么跟STL的一毛一样?这不是诱惑我吗?
(/≧▽≦)/
什么都不说了,晒图了
AC

猜你喜欢

转载自blog.csdn.net/Walikrence/article/details/83049026