FIND_MAX Editorial

PROBLEM LINK:

[Practice](CodeChef: Practical coding for everyone FIND_MAX)

Author: RushikeshThakare
Tester: YogeshDeolalkar
Editorialist: RushikeshThakare

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Math

PROBLEM:

Yogesh got his three subject marks in MathsMaths, PhysicsPhysics and ChemistryChemistry from college. Now he want to find out in which subject he get highesthighest marksmarks. The marks in Maths is A , physics is B and chemistry is C.

QUICK EXPLANATION:

The subject in which he get highest number

SOLUTIONS:

Setter's Solution

#include
using namespace std;

int main()
{
int a,b,c;

 cin >> a  >> b >> c;

if(a >= b && a >= c)
    cout << "Maths"; 
     cout<<endl;
if(b >= a && b >= c)
    cout << "Physics "; 

  cout<<endl;
if(c >= a && c >= b)
    cout << "Chemistry ";   cout<<endl;


return 0;

}

Tester's Solution

#include <stdio.h>

int main(void) {
int a,b,c;
scanf(“%d %d %d”,&a,&b,&c);
if(a>b&&a>c)
{
printf(“Maths\n”);
}
else if(b>a&&b>c)
{
printf(“Physics\n”);
}
else if(c>a&&c>b)
{
printf(“Chemistry\n”);
}
return 0;
}

Editorialist's Solution

#include
using namespace std;

int main() {
int a, b, c;

cin >> a;

cin >> b;

cin >> c;

switch (a > b)
{
    case 1 :
    switch ( a > c )
{
    case 1 :
    cout <<"maths";
    break;
    case 0 :
    cout <<"chemistry";
}
    break;
    case 0 : 
    switch (b > c) 
{  
    case 1 :
    cout << "physics";
    break ;
    case 0:
    cout <<"chemistry";
    break;
}
    break;
}
    
    
// your code goes here
return 0;

}