-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4function.cpp
58 lines (47 loc) · 839 Bytes
/
4function.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
57
58
/*Input Format
Input will contain four integers -a,b,c,d , one per line.
Output Format
Return the greatest of the four integers.
PS: I/O will be automatically handled.
Sample Input
3
4
6
5
Sample Output
6*/
#include <iostream>
#include <cstdio>
using namespace std;
/*
Add `int max_of_four(int a, int b, int c, int d)` here.
*/
int max_of_four(int a, int b, int c, int d){
if(a > b){
if(a > c){
if(a>d)return a;
else return d;
}
else {
if(c > d)return c;
else return d;
}
}
else{
if(b > c){
if(b > d)return b;
else return d;
}
else{
if(c > d)return c;
else return d;
}
}
}
int main() {
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
int ans = max_of_four(a, b, c, d);
printf("%d", ans);
return 0;
}