include iostream using namespace std function to find the maximum valu

 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
#include <iostream>
using namespace std;
//function to find the maximum value
double min(double x, double y)
{
if ( x < y ) {
return x;
} else {
return y;
}
}
//function to find the minimum value
double max(double x, double y)
{
if ( x > y ) {
return x;
} else {
return y;
}
}
int main()
{
int a, b, c, amount, intermediate;
cout << "Input the a, b, c: " << endl;
cin >> a >> b >> c;
intermediate = a + b + c;
//the first condition
if ( intermediate >= 0 )
{
amount = 0.5 * max( a, max( b, c ) ) + a;
}
//the second condition
if ( intermediate < 0 ) && ( a >= 0 )
{
amount = 2.1 * ( 1 - a * a ) + cos( b / ( c + 1 ) );
}
//the third condition
if ( intermediate < 0 ) && ( a < 0 )
{
amount = a * a + min( b, c )
}
cin.get();
cout << "Final answer: " << amount << endl;
}