fork download
  1. #include <cstdlib>
  2. #include <algorithm>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. template<typename TYPE>
  8. void sort3(TYPE n1, TYPE n2, TYPE n3) {
  9. TYPE arr[3];
  10. arr[0] = n1;
  11. arr[1] = n2;
  12. arr[2] = n3;
  13. sort(arr + 0, arr + 3);
  14.  
  15. for (int i = 0; i < 3; i++) {
  16. cout << arr[i] << " ";
  17. }
  18. cout << endl;
  19. }
  20.  
  21. int main(int argc, char** argv) {
  22. sort3("B", "Z", "A");
  23. sort3(10.2, 99.0, 1.9);
  24. sort3(200, 50, 1);
  25. return 0;
  26.  
  27. }
  28.  
Success #stdin #stdout 0s 2900KB
stdin
Standard input is empty
stdout
A Z B 
1.9 10.2 99 
1 50 200