Twist_Nemo

function_ hackerrank.cpp

Jun 11th, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5.  
  6. int max_of_four(int a, int b, int c, int d) {
  7.     if(a > b){
  8.     if(a > c){
  9.         if(a>d)return a;
  10.         else return d;
  11.     }
  12.     else {
  13.         if(c > d)return c;
  14.         else return d;
  15.     }
  16. }
  17. else{
  18.     if(b > c){
  19.         if(b > d)return b;
  20.         else return d;
  21.     }
  22.     else{
  23.         if(c > d)return c;
  24.         else return d;
  25.     }
  26. }
  27. }
  28.  
  29.  
  30. int main() {
  31.     int a, b, c, d;
  32.     scanf("%d %d %d %d", &a, &b, &c, &d);
  33.     int ans = max_of_four(a, b, c, d);
  34.     printf("%d", ans);
  35.    
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment