Skip to content

Commit

Permalink
stack cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishak798 authored Feb 10, 2024
1 parent c9206c7 commit 41baed1
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Stack/stack.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
stack<int> st[10];
// st[0].push(1);
// st[1].push(2);
// st[2].push(3);
// st[3].push(4);
// st[4].push(5);
int element;
for (int i = 0; i < 5; i++)
{
cout << "enter element: ";
cin >> element;
while (st[i].empty())
{
st[i].push(element);
}
cout << endl;
}
for (int i = 0; i < 5; ++i)
{
cout << "Stack " << i << " elements: ";
while (!st[i].empty())
{
cout << st[i].top() << " ";
st[i].pop();
}
cout << endl;
}

return 0;
}
/*enter element: 1
enter element: 2
enter element: 3
enter element: 4
enter element: 5
Stack 0 elements: 1
Stack 1 elements: 2
Stack 2 elements: 3
Stack 3 elements: 4
Stack 4 elements: 5*/
Binary file added Stack/stack.exe
Binary file not shown.
5 changes: 5 additions & 0 deletions Stack/tempCodeRunnerFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// st[0].push(1;
// st[1].push(2);
// st[2].push(3);
// st[3].push(4);
// st[4].push(5);

0 comments on commit 41baed1

Please sign in to comment.