-
Notifications
You must be signed in to change notification settings - Fork 7
/
main13.cpp
56 lines (39 loc) · 908 Bytes
/
main13.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
using namespace std;
class ComplexT{
public:
ComplexT(float n, float p){
re = n;
im = p;
}
bool operator>(const ComplexT& z) const{
float f1 = re * re + im * im;
float f2 = z.re * z.re + z.im * z.im;
return f1 > f2;
}
friend ostream &operator<<( ostream &output, const ComplexT &D){
output << D.re << "," << D.im << endl;
return output;
}
float im;
float re;
};
template <class T>
const T & MAX(const T &v1, const T &v2) {
if (v1 > v2)
return v1;
else
return v2;
}
int main() {
int i1=5, i2= -3;
char c1='D', c2='N';
float f1=3.05, f2=12.47;
ComplexT z2(4.6, (float)-3.8);
ComplexT z1(1.4, 0.6);
cout << MAX(i1,i2) << endl;
cout << MAX(c1,c2) << endl;
cout << MAX(f1,f2) << endl;
cout << MAX(z1,z2) << endl;
return 0;
}