Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unordered_map>
- #include <iostream>
- int total = 1;
- typedef std::unordered_map<char, bool> mapa;
- typedef std::unordered_map<int, mapa> stu_mapa;
- stu_mapa STU_mapa;
- void add(char letter, bool verdade) {
- std::unordered_map<char, bool> ma_pa;
- ma_pa[letter] = verdade;
- STU_mapa.insert(stu_mapa::value_type(total, ma_pa));
- total ++;
- return;
- }
- int main() {
- std::cout << "Inicio" << std::endl;
- add('a',false);
- add('b',false);
- add('c',false);
- add('d',true);
- add('e',true);
- add('f',false);
- for(stu_mapa::reverse_iterator j = STU_mapa.rbegin(); j!=STU_mapa.rend(); j++) {
- std::unordered_map<char, bool> ma_pa = j->second;
- std::unordered_map<char, bool>::const_iterator k = ma_pa.begin();
- if(k->second == true) {
- std::cout << "delete " << j->first << std::endl;
- STU_mapa.erase(j->first);
- j--;
- }
- else {
- std::cout << j->first << std::endl;
- }
- }
- std::cout << "desce" << std::endl << std::endl;
- for(stu_mapa::reverse_iterator j = STU_mapa.rbegin(); j!=STU_mapa.rend(); j++) {
- std::cout << j->first << std::endl;
- }
- system("pause");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement