Skip to content

Commit 22c5ec5

Browse files
Stack Implementation using STL Built in stack
1 parent 9622f4a commit 22c5ec5

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

input.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
5
2-
10 20 30 40 50
2+
100 200 300 400 500

output.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
50
2-
40
3-
30
4-
20
5-
10
1+
500
2+
400
3+
300
4+
200
5+
100

stl_stack.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
stack<int> st;
7+
int n;
8+
cin >> n;
9+
while (n--)
10+
{
11+
int x;
12+
cin >> x;
13+
st.push(x);
14+
}
15+
16+
while (!st.empty())
17+
{
18+
cout << st.top() << endl;
19+
st.pop();
20+
}
21+
22+
return 0;
23+
}

stl_stack.exe

80.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)