fork download
  1. #include <iostream>
  2. #include <map>
  3. #include <functional>
  4.  
  5. int main() {
  6. std::map<double,int,std::greater<double>> list;
  7. list.emplace(100,1);
  8. list.emplace(0,2);
  9. list.emplace(2.71,3);
  10. list.emplace(3.14,4);
  11. list.emplace(1.41,5);
  12.  
  13. for(auto &v : list){
  14. std::cout << "number:" << v.second << " score:" << v.first << std::endl;
  15. }
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
number:1 score:100
number:4 score:3.14
number:3 score:2.71
number:5 score:1.41
number:2 score:0