fork(2) download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. template<class T>
  5. const T& clamp(const T& value, const T& maxValue, const T& minValue) {
  6. return std::max(maxValue, std::min(value, minValue));
  7. }
  8.  
  9. int main(void)
  10. {
  11. for (int i = 0; i < 20; i++)
  12. {
  13. std::cout << clamp(i, 0, 10) << std::endl;
  14. }
  15.  
  16. system("pause");
  17. return 0;
  18. }
Success #stdin #stdout #stderr 0s 4476KB
stdin
Standard input is empty
stdout
0
1
2
3
4
5
6
7
8
9
10
10
10
10
10
10
10
10
10
10
stderr
sh: 1: pause: not found