Created
May 21, 2019 22:18
-
-
Save Thiago4532/ee62aa8a284de9063bb113575b90d7f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stack> // Biblioteca da stack | |
using namespace std; | |
int main() { | |
stack<int> pilha; // Declaro a stack do tipo int | |
pilha.push(1); // Insiro o elemento 1 no topo da pilha | |
pilha.push(3); // Insiro o elemento 3 no topo da pilha | |
pilha.push(7); // Insiro o elemento 7 no topo da pilha | |
cout << pilha.top() << "\n"; // Retorna o valor 7 | |
pilha.pop(); // Removo o topo da pilha | |
cout << pilha.top() << "\n"; // Retorna o valor 5 | |
pilha.pop(); | |
cout << pilha.top() << "\n"; // Retorna o valor 1 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment