c++ stack
C++
// CPP program to illustrate
// Implementation of push() function
#include <iostream>
#include <stack>
using namespace std;
int main()
{
// Empty stack
stack<int> mystack;
mystack.push(0);
mystack.push(1);
mystack.push(2);
// Printing content of stack
while (!mystack.empty()) {
cout << ' ' << mystack.top();
mystack.pop();
}
}
stack<int> stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5// CPP program to demonstrate working of STL stack
#include <bits/stdc++.h>
using namespace std;
void showstack(stack <int> s)
{
while (!s.empty())
{
cout << '\t' << s.top();
s.pop();
}
cout << '\n';
}
int main ()
{
stack <int> s;
s.push(10);
s.push(30);
s.push(20);
s.push(5);
s.push(1);
cout << "The stack is : ";
showstack(s);
cout << "\ns.size() : " << s.size();
cout << "\ns.top() : " << s.top();
cout << "\ns.pop() : ";
s.pop();
showstack(s);
return 0;
}
Also in C++:
- Title
- differentialble programming
- Category
- C++
- Title
- object slicing in c++
- Category
- C++
- Title
- invalid types int int for array subscript c++
- Category
- C++
- Title
- c++ overloaded equality check operator
- Category
- C++
- Title
- how to make string get spaces c++
- Category
- C++
- Title
- c++ create array
- Category
- C++
- Title
- initialize array c++
- Category
- C++
- Title
- graph using djacency matrix c++
- Category
- C++
- Title
- Runtime Error: Runtime ErrorBad memory access (SIGBUS)
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- random number in c++
- Category
- C++
- Title
- hobo 8
- Category
- C++
- Title
- how to create object in c++
- Category
- C++
- Title
- preorder traversal c++
- Category
- C++
- Title
- singleton c++
- Category
- C++
- Title
- cube mapping sdl
- Category
- C++
- Title
- constant variables in c++
- Category
- C++
- Title
- how to delete a node c++
- Category
- C++
- Title
- variant hold type
- Category
- C++
- Title
- c++ get ascii value of char
- Category
- C++
- Title
- is TLE means my code is correct but taking more time to computr
- Category
- C++
- Title
- memcmp in cpp
- Category
- C++
- Title
- how to convert int to string c++
- Category
- C++
- Title
- initialize vector of vector c++
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- c++ for loop
- Category
- C++
- Title
- cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
- Category
- C++
- Title
- access last element in vector in c++
- Category
- C++
- Title
- convert string to stream c++
- Category
- C++
- Title
- empty string c++ value
- Category
- C++
- Title
- c++ ambigous error
- Category
- C++
- Title
- how to convert n space separated integers in c++
- Category
- C++
- Title
- initialize 2d array c++
- Category
- C++
- Title
- c++ clear stream
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- find all occurrences of a substring in a string c++
- Category
- C++
- Title
- c++ switch
- Category
- C++
- Title
- c++ declare char
- Category
- C++
- Title
- length of string c++
- Category
- C++
- Title
- bitset c++
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- best fit algorithm
- Category
- C++
- Title
- how do for loops on c++
- Category
- C++
- Title
- c++ how to add something at the start of a vector
- Category
- C++
- Title
- how to print 5 precision float in c++
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- switch statement c++
- Category
- C++
- Title
- double max value c++
- Category
- C++
- Title
- runtime array size c++
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- c++ find prime numbers
- Category
- C++
- Title
- c++ evaluate expression
- Category
- C++
- Title
- cloud hosting
- Category
- C++
- Title
- printf c++
- Category
- C++
- Title
- how to extract substring from string in c++
- Category
- C++
- Title
- count function c++
- Category
- C++
- Title
- euler's totient function c++
- Category
- C++
- Title
- iterate 2d array c++
- Category
- C++
- Title
- built in function in c++ for binary to decimal
- Category
- C++
- Title
- for c++
- Category
- C++
- Title
- how to round to nearest whole number unity
- Category
- C++
- Title
- max element in array c++ stl
- Category
- C++
- Title
- adding element in vector c++
- Category
- C++
- Title
- how to use wasd c++
- Category
- C++
- Title
- class in c++
- Category
- C++
- Title
- monotonic deque
- Category
- C++
- Title
- make an x using asterisk c++
- Category
- C++
- Title
- vprintf
- Category
- C++
- Title
- mingw32/bin/ld.exe: C:\Users\mfrom\AppData\Local\Temp\ccSKcRks.o:PizzaPi.cpp:(.text$_ZN5PizzaC2Ev[__ZN5PizzaC2Ev]+0xa): undefined reference to `vtable for Pizza' collect2.exe: error: ld returned 1 exit status
- Category
- C++
- Title
- how to swap string characters in c++
- Category
- C++
- Title
- c++ vector constructors
- Category
- C++
- Title
- tellg and seekg c++
- Category
- C++
- Title
- switch c++
- Category
- C++
- Title
- how to sort in descending order c++
- Category
- C++
- Title
- how to make an array c++
- Category
- C++
- Title
- cpp loop through object
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- c++ clear console
- Category
- C++
- Title
- what is difference between single inverted and double inverted in programming languages
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- roscpp publish int32
- Category
- C++
- Title
- range of long long in c++
- Category
- C++
- Title
- how to iterate through a map in c++
- Category
- C++
- Title
- initialize map c++
- Category
- C++
- Title
- c++ scanf
- Category
- C++
- Title
- get index of value c++
- Category
- C++
- Title
- convert int to string c++
- Category
- C++
- Title
- prefix sum array
- Category
- C++
- Title
- c++ main function
- Category
- C++
- Title
- calculate sum in c++
- Category
- C++
- Title
- check for bst
- Category
- C++
- Title
- run program until ctrl-d c++
- Category
- C++
- Title
- building native binary with il2cpp unity
- Category
- C++
- Title
- what does count function do in hashmap
- Category
- C++
- Title
- insertion c++
- Category
- C++
- Title
- swapo algorit
- Category
- C++
- Title
- dijkstra in c++
- Category
- C++
- Title
- knapsack
- Category
- C++
- Title
- COnvert string to char * C++
- Category
- C++
- Title
- peak in c++
- Category
- C++