Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. /*
  6. Add `int max_of_four(int a, int b, int c, int d)` here.
  7. */
  8.  
  9. template<typename T>
  10. T my_max(T a, T b)
  11. {
  12.     return (a > b ? a : b);
  13. }
  14.  
  15. template<typename T, typename ... Types>
  16. T my_max(T a, Types ... types)
  17. {
  18.     return my_max(a, my_max(types...));
  19. }
  20.  
  21. int max_of_four(int a, int b, int c, int d)
  22. {
  23.     return my_max(a, b, c, d);
  24. }
  25.  
  26.  
  27. int main() {
  28.     int a, b, c, d;
  29.     scanf("%d %d %d %d", &a, &b, &c, &d);
  30.     int ans = max_of_four(a, b, c, d);
  31.     printf("%d", ans);
  32.    
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement