Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <class T> T maximum(T a, T b) {
- if (a > b) {
- return a;
- }
- else {
- return b;
- }
- }
- template <class T> T apsolute(T x)
- {
- if (x < 0)
- x = x * (-1);
- return x;
- }
- int main() {
- int a = 3, b = 5;
- double c = 3.1, d = 5.2;
- cout << maximum(a, b) << endl;
- cout << maximum(c, d) << endl;
- int e = -1, f = -2;
- double g = 5.3, h = -3.2;
- cout << apsolute(e) << endl;
- cout << apsolute(f) << endl;
- cout << apsolute(g) << endl;
- cout << apsolute(h) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement