Sort by

recency

|

2001 Discussions

|

  • + 0 comments
    int max(int a, int b){
        return a > b? a:b;
    }
    
    int main() {
        int a,b,c,d;
        cin >> a >>b >>c>>d;
        
        int sol = max(a, b);
        sol  = max(sol, c);
        sol = max(sol, d);
        
        cout << sol;
        return 0;
    }
    
  • + 0 comments

    include

    include

    using namespace std;

    int max_of_four(int a, int b, int c, int d){

    if(a>b&&a>c&&a>d){
        return a;
    }
    else if(b>a&&b>c&&b>d){
        return b;
    
    }
    else if(c>a&&c>b&&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;
    

    }

  • + 0 comments
    #include <iostream>
    #include <cstdio>
    using namespace std;
    
    int max_of_four(int a, int b, int c, int d);
    int greaterOfTwo(int a, int b);
    
    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;
    }
    int max_of_four(int a, int b, int c, int d);
    int greaterOfTwo(int a, int b);
    
    
    int max_of_four(int a, int b, int c, int d)
    {
        int max = 0;
        max = greaterOfTwo(a, b);
        max = greaterOfTwo(max, c);
        max = greaterOfTwo(max, d);
        return max;
    }
    
    int greaterOfTwo(int a, int b)
    {
        return a > b ? a : b;
    }
    
  • + 0 comments

    include

    include

    include

    using namespace std;

    int main(){ int list[4]; for (int i = 0 ; i < 4 ; i++) { cin >> list[i]; } if (list[0] > list[1] && list[0] > list[2] && list[0] > list[3]) { cout << list[0]; } else if (list[1] > list[0] && list[1] > list[2] && list[1] > list[3]) { cout << list[1]; } else if (list[2] > list[0] && list[2] > list[1] && list[2] > list[3]) { cout << list[2]; } else{ cout << list[3]; }

    }

  • + 0 comments

    include

    include

    include

    using namespace std;

    int main(){ int list[4]; for (int i = 0 ; i < 4 ; i++) { cin >> list[i]; } if (list[0] > list[1] && list[0] > list[2] && list[0] > list[3]) { cout << list[0]; } else if (list[1] > list[0] && list[1] > list[2] && list[1] > list[3]) { cout << list[1]; } else if (list[2] > list[0] && list[2] > list[1] && list[2] > list[3]) { cout << list[2]; } else{ cout << list[3]; }

    }