-
Notifications
You must be signed in to change notification settings - Fork 0
/
try.cpp
54 lines (47 loc) · 893 Bytes
/
try.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SampleCpp.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <vector>
using namespace std;
template <typename _T, template <typename _Ty, class _Ax = allocator<_Ty> > class container>
class Stack
{
public:
Stack() { }
void push(const _T& elem)
{
v1.push_back(elem);
}
void pop()
{
v1.pop_back();
}
const _T& top() const
{
return v1[v1.size()-1];
}
bool empty() const
{
return (v1.front() == NULL);
}
private:
container<_T> v1;
};
int main()
{
Stack<int, vector> s;
int d;
while(cin>>d)
{
s.push(d);
}
while(!s.empty())
{
cout<<s.top()<<endl;
s.pop();
}
#ifdef WIN32
system("PAUSE");
#endif // WIN32
return 0;
}