fork(1) download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4.  
  5. int main() {
  6. std::map<int,std::string> m = {
  7. {1,"1"},
  8. {2,"2"},
  9. {3,"3"},
  10. {4,"4"},
  11. {5,"5"},
  12. {6,"6"},
  13. {7,"7"},
  14. {8,"8"},
  15. };
  16. int i = 0;
  17. for(auto it = --m.end();it != m.begin();--it,++i){
  18. if(i>4){break;}
  19. std::cout << it->first << ':' << it->second <<std::endl;
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 4304KB
stdin
Standard input is empty
stdout
8:8
7:7
6:6
5:5
4:4