This file contains 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
v.pop_back(); // Remove o último elemento |
This file contains 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
// v = {1, 2, 3, 4, 5} | |
v.resize(8); // Muda o tamanho do vector v para 5. | |
// v = {1, 2, 3, 4, 5, 0, 0, 0} |
This file contains 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 <vector> // Biblioteca que contem a estrutura vector | |
#include <algorithm> // Biblioteca do sort | |
using namespace std; | |
int main() { | |
vector<int> v; // Declaracao de um vector do tipo int | |
v.push_back(3); // Insiro o elemento 3 no final do vetor | |
v.push_back(1); // Insiro o elemento 1 no final do vetor |
This file contains 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 | |
return 0; | |
} |
This file contains 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 |
This file contains 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 |
This file contains 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 <iostream> // Necessita da iostream para funcionar | |
using namespace std; | |
int main() { | |
pair<string, int> p; // Declara um pair de string e int | |
p.first = "Thiago"; | |
p.second = 2; |
This file contains 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 <iostream> // Necessita da iostream para funcionar | |
using namespace std; | |
int main() { | |
pair< pair<int, string> , int> p; | |
p.first.first = 100; // Acessa o primeiro elemento do pair de dentro. | |
p.first.second = "Lawrence"; // Acessa o segundo elemento do pair de dentro. |
This file contains 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 <iostream> // Necessita da iostream para funcionar | |
using namespace std; | |
int main() { | |
pair<int, string> A = {10, "Thiago"}; | |
pair<int, string> B = {20, "Lawrence"}; | |
pair<int, string> C = {20, "Davi"}; | |
if(A < B) { |
This file contains 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 <iostream> // Necessita da iostream para funcionar | |
using namespace std; | |
int main() { | |
vector< pair<int, int> > v = { {10, 1}, {1, 3}, {1, 2}, {2, 4}, {3, 5} }; // Declarando um vector de pair | |
// v = { (10, 1), (1, 3), (1, 2), (2, 4), (3, 5) } | |
sort(v.begin(), v.end()); |