Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int min(int n_1, int n_2);
- float min(float f_1, float f_2);
- template <class T> T _min(T, T);
- /////////////////////////////////////////////////////
- int main() //
- {
- int n1 = 11,
- n2 = 2;
- float f1 = 11.1,
- f2 = 2.2;
- int nRes = _min(n1, n2); printf("nRes = %d \n", nRes);
- float fRes = _min(f1, f2); printf("fRes = %.2f\n", fRes);
- return 0;
- }
- template <typename T>
- /////////////////////////////////////////////////////
- T _min(T t1, T t2) //
- {
- if(t1 > t2) return t2;
- else return t1;
- }
- /////////////////////////////////////////////////////
- int min(int n_1, int n_2) //
- {
- if(n_1 > n_2) return n_2;
- else return n_1;
- }
- /////////////////////////////////////////////////////
- float min(float f_1, float f_2) //
- {
- printf("Hello from float min()! \n");
- if(f_1 > f_2) return f_2;
- else return f_1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement