stack c++
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
- C++ If
- Category
- C++
- Title
- conditional operator in cpp
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- stringstream in c++
- Category
- C++
- Title
- c++ char if
- Category
- C++
- Title
- convert decimal to binary in c++
- Category
- C++
- Title
- c++ menu selection with arrow keys
- Category
- C++
- Title
- how to convert string into number
- Category
- C++
- Title
- linear search in c++
- Category
- C++
- Title
- c++ convert int to double
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- How to check if a triangular cycle exists in a graph
- Category
- C++
- Title
- unsorted array to bst
- Category
- C++
- Title
- first fit algorithm
- Category
- C++
- Title
- primos menores que
- Category
- C++
- Title
- pionter in c++
- Category
- C++
- Title
- programa para saber si un numero es primo
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- Read multiple files(.txt) c++
- Category
- C++
- Title
- exponenciacion binaria
- Category
- C++
- Title
- how to run c++ file mingw cmd
- Category
- C++
- Title
- flake8 max line length
- Category
- C++
- Title
- modulo c++
- Category
- C++
- Title
- memset c++
- Category
- C++
- Title
- program to know if a number is prime
- Category
- C++
- Title
- how to delete a node c++
- Category
- C++
- Title
- find height of a tree
- Category
- C++
- Title
- cout value c++
- Category
- C++
- Title
- how to switch to another branch in git
- Category
- C++
- Title
- differentialble programming
- Category
- C++
- Title
- case label in c++
- Category
- C++
- Title
- cpp how to create an object of template class
- Category
- C++
- Title
- Convert binary tree to a doubly linked list
- Category
- C++
- Title
- c++ while true
- Category
- C++
- Title
- c++ convert int to cstring
- Category
- C++
- Title
- two elements with difference K in c++
- Category
- C++
- Title
- border radius layout android xml
- Category
- C++
- Title
- how to sort an array according to another array c++
- Category
- C++
- Title
- inheritance protected in c++
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- power in c++
- Category
- C++
- Title
- minimum swaps to sort an array
- Category
- C++
- Title
- c++ while true loop
- Category
- C++
- Title
- c++ round to int
- Category
- C++
- Title
- converting char to int in c++
- Category
- C++
- Title
- c++ get last element in vector
- Category
- C++
- Title
- array search c++
- Category
- C++
- Title
- how to get the largest number in a c++ array
- Category
- C++
- Title
- c++ tutorial
- Category
- C++
- Title
- c++ replace substrings
- Category
- C++
- Title
- c++ multiple inheritance diamond problem
- Category
- C++
- Title
- How to find the suarray with maximum sum using divide and conquer
- Category
- C++
- Title
- max three values c++
- Category
- C++
- Title
- how to run a c++ program in the background
- Category
- C++
- Title
- vector concat c++
- Category
- C++
- Title
- c++ loop through int array
- Category
- C++
- Title
- how to include seld declared header file in c++
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- c++ ros subscriber
- Category
- C++
- Title
- how to load from files C++
- Category
- C++
- Title
- inverser les éléments d'un tableau manuellement en c++
- Category
- C++
- Title
- properties of a set c++
- Category
- C++
- Title
- c++ get type name of object
- Category
- C++
- Title
- function template
- Category
- C++
- Title
- remove value from vector c++
- Category
- C++
- Title
- c++ while loop code
- Category
- C++
- Title
- translate
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- delete files c++
- Category
- C++
- Title
- c++ class inheritance
- Category
- C++
- Title
- multiple words C++ in same
- Category
- C++
- Title
- how to delete something in an array c++
- Category
- C++
- Title
- compare string c++
- Category
- C++
- Title
- c++ how to return an empty vector
- Category
- C++
- Title
- c++ push multiple elements to vector
- Category
- C++
- Title
- Rectangle area hackerrank solution in c++
- Category
- C++
- Title
- hashmap in c++
- Category
- C++
- Title
- monotonic deque
- Category
- C++
- Title
- mkdir boost filesystem
- Category
- C++
- Title
- if esle in c++
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- char vector to string c++
- Category
- C++
- Title
- how the theam are store in database
- Category
- C++
- Title
- maximum possible number atmost k swaps
- Category
- C++
- Title
- nearest integer rounding in c++
- Category
- C++
- Title
- map arduino
- Category
- C++
- Title
- c++ char to int
- Category
- C++
- Title
- c++ string^ to char*
- Category
- C++
- Title
- vector initialization c++
- Category
- C++
- Title
- basic ex of maps in c++
- Category
- C++
- Title
- number of islands leetcode code
- Category
- C++
- Title
- double to int c++
- Category
- C++
- Title
- elseif c++
- Category
- C++
- Title
- chess perft 5
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- find vector in c++
- Category
- C++
- Title
- how use global variables instead of local in c++
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- vector stl c++
- Category
- C++
- Title
- file format not recognized treating as linker script c++
- Category
- C++