fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename T>
  5. bool mniejsze (T pierwszy , T drugi){
  6. if( pierwszy < drugi)
  7. return true;
  8. return false;
  9. }
  10.  
  11. template <typename T>
  12. bool wieksze (T pierwszy, T drugi){
  13. if( pierwszy > drugi )
  14. return true;
  15. return false;
  16. }
  17.  
  18. template<typename T>
  19. struct f {
  20. typedef bool( *type)( T, T );
  21. };
  22.  
  23. template<typename T>
  24. T minmax(T a[], int n, bool b, typename f<T>::type fp ){
  25. if ( fp( a[0], a[1])) return 1;
  26. return -1;
  27. }
  28.  
  29. int main() {
  30. // your code goes here
  31. f<int>::type f1 = mniejsze<int>;
  32. bool b = f1( 3, 4);
  33. int a[] = { 3, 4};
  34. std::cout << minmax<int>( a, 0, 0, f1);
  35. return 0;
  36. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1