K. Max and Min – Codeforces Problem Solution in C++

Disclaimer: Make sure you tried enough before checking the solution

Problem: https://codeforces.com/group/MWSDmqGsZm/contest/219158/problem/K

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int num1,num2,num3; 
	cin>>num1>>num2>>num3;
	if(num1>= num2 && num1>=num3){ 
		if(num2 > num3){
			cout<<num3<<" "<<num1<<endl;
		} else {
			cout<<num2<<" "<<num1<<endl;
		}
	} else if (num2 >= num1 && num2 >= num3){ // num2 *
		if(num1 > num3){
			cout<<num3<<" "<<num2<<endl;
		} else {
			cout<<num1<<" "<<num2<<endl;
		}
	} else if(num3 >= num2 && num3 >= num1) { // num3 *
		if(num1 > num2){
			cout<<num2<<" "<<num3<<endl;
		} else {
			cout<<num1<<" "<<num3<<endl;
		}
	}
}

Assiut University Training – Newcomers solution

Leave a Comment