fork download
  1. // min & max example
  2. // http://w...content-available-to-author-only...s.com/reference/algorithm/min/
  3. // http://w...content-available-to-author-only...s.com/reference/algorithm/max/
  4. #include <iostream> // std::cout
  5. #include <algorithm> // std::min std::max
  6.  
  7. int main () {
  8. std::cout << "min(1,2)==" << std::min(1,2) << '\n';
  9. std::cout << "min(2,1)==" << std::min(2,1) << '\n';
  10. std::cout << "min('a','z')==" << std::min('a','z') << '\n';
  11. std::cout << "min(3.14,2.72)==" << std::min(3.14,2.72) << '\n';
  12. std::cout << "max(1,2)==" << std::max(1,2) << '\n';
  13. std::cout << "max(2,1)==" << std::max(2,1) << '\n';
  14. std::cout << "max('a','z')==" << std::max('a','z') << '\n';
  15. std::cout << "max(3.14,2.72)==" << std::max(3.14,2.72) << '\n';
  16. return 0;
  17. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
min(1,2)==1
min(2,1)==1
min('a','z')==a
min(3.14,2.72)==2.72
max(1,2)==2
max(2,1)==2
max('a','z')==z
max(3.14,2.72)==3.14