Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int fakt(int n)
- {
- if ( n == 0) return 1;
- return n * fakt(n - 1);
- }
- #include <iostream>
- using namespace std;
- template <typename T> T maxi(T a, T b)
- {
- if (a > b) return a;
- return b;
- }
- template <typename T> T maxi(T a, T b, T c)
- {
- return maxi(maxi(a,b),c);
- }
- template <typename T> T maxi(T a, T b, T c, T d)
- {
- return maxi(maxi(a,b),maxi(c,d));
- }
- int main()
- {
- cout<<maxi(10, 23)<<endl;
- cout<<maxi(10.1,10.2)<<endl;
- cout<<maxi(1,2,3)<<endl;
- cout<<maxi(1,4,3,2)<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment