stack function in cpp
C++
// 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;
}
stack<int> stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5
Also in C++:
- Title
- rgb(100,100,100,0.5) validation c++
- 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
- Find a element in a map C++
- Category
- C++
- Title
- c++ pointers
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- copy a part of a vector in another in c++
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- c++ loop through array
- Category
- C++
- Title
- sort function in c++
- Category
- C++
- Title
- c++ function return pointer to itself
- Category
- C++
- Title
- how to output text in c++
- Category
- C++
- Title
- c++ short if
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- c++ clear console
- Category
- C++
- Title
- c++ char print width
- Category
- C++
- Title
- caesar cipher program in c++
- Category
- C++
- Title
- loop c++
- Category
- C++
- Title
- convert int to string c++
- Category
- C++
- Title
- c++ std::copy to cout
- Category
- C++
- Title
- getch c++ library
- Category
- C++
- Title
- how to switch to another branch in git
- Category
- C++
- Title
- singleton c++
- Category
- C++
- Title
- 1d fixed length arrays c++
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- c++ class member initialization
- Category
- C++
- Title
- fast input output in c++
- Category
- C++
- Title
- find vector in c++
- Category
- C++
- Title
- traverse a map
- Category
- C++
- Title
- c++ cli convert string to string^
- Category
- C++
- Title
- getline in c++
- Category
- C++
- Title
- program to know if a number is prime
- Category
- C++
- Title
- residuo en lenguaje c
- Category
- C++
- Title
- file objects in c++
- Category
- C++
- Title
- declaring 2d vector in c++
- Category
- C++
- Title
- linear search in c++
- Category
- C++
- Title
- two elements with difference K in c++
- Category
- C++
- Title
- c++ initialization list
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- transpose matrix eigen c++
- Category
- C++
- Title
- unsorted array to bst
- Category
- C++
- Title
- is not a nonstatic data member or base class of class
- Category
- C++
- Title
- fill c++
- Category
- C++
- Title
- qt make widget ignore mouse events
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- find height of a tree
- Category
- C++
- Title
- c++ formatting
- Category
- C++
- Title
- what does count function do in hashmap
- Category
- C++
- Title
- how to append one vector to another c++
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- iterate 2d array c++
- Category
- C++
- Title
- Combination Sum
- Category
- C++
- Title
- how to iterate over unordered_map c++
- Category
- C++
- Title
- bitset c++
- Category
- C++
- Title
- how to load from files C++
- Category
- C++
- Title
- c++ comment
- Category
- C++
- Title
- sub string of vector c++
- Category
- C++
- Title
- set of vectors c++
- Category
- C++
- Title
- max element in array c++ stl
- Category
- C++
- Title
- check if intent has extras
- Category
- C++
- Title
- c++ how to skip the last element of vector
- 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
- least number of coins to form a sum
- Category
- C++
- Title
- dynamic 2d array c++
- Category
- C++
- Title
- for c++
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- c++ ambigous error
- Category
- C++
- Title
- initialize array c++
- Category
- C++
- Title
- binary search in set c++
- Category
- C++
- Title
- index string c++
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- c++ excel cell blank cells
- Category
- C++
- Title
- Find the duplicate in an array of N integers.
- Category
- C++
- Title
- Check if a Number is Odd or Even using Bitwise Operators
- Category
- C++
- Title
- C++ and endl
- Category
- C++
- Title
- UPARAM(ref)
- Category
- C++
- Title
- how to run a c++ program in the background
- Category
- C++
- Title
- how to concatinate two strings in c++
- Category
- C++
- Title
- how to convert string into number
- Category
- C++
- Title
- c++ remove space from string
- Category
- C++
- Title
- new keyword in cpp
- Category
- C++
- Title
- c++ give options
- Category
- C++
- Title
- vector stl c++
- Category
- C++
- Title
- C++ w3schools
- Category
- C++
- Title
- how to sort a vector in reverse c++
- Category
- C++
- Title
- c++ return multiple values
- Category
- C++
- Title
- expected initializer before 'isdigit'|
- Category
- C++
- Title
- c++ how to make a negative float positive
- Category
- C++
- Title
- Html tabulation
- Category
- C++
- Title
- stringstream in c++ with delimiter
- Category
- C++
- Title
- c++ sort
- Category
- C++
- Title
- passing reference in c++
- Category
- C++
- Title
- c++ string contains
- Category
- C++
- Title
- substr in c++
- Category
- C++
- Title
- convert stirng to int c++
- Category
- C++
- Title
- how to use wasd c++
- Category
- C++
- Title
- how to get input from the console in c++
- Category
- C++
- Title
- how to append two vectors in c++
- Category
- C++
- Title
- memcmp in cpp
- Category
- C++
- Title
- removing repeated characters in a string c++
- Category
- C++