Algorithm


Problem Name: beecrowd | 3301

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/3301

Middle Nephew

 

By Ricardo Martins, Instituto Federal do Sul de Minas Gerais BR Brazil

Timelimit: 1

Uncle Patinhas was a millionaire who lived in his mansion, and he had three nephews: Huguinho, Zezinho and Luisinho. He was easily confused between the three nephews because they were very similar, despite their different ages. One day, the three made a bet with their uncle: if he guessed who the middle nephew was, that is, neither the youngest nor the oldest, they would give him a gold coin, and if he missed, he would have to give each one a gold coin. So the uncle asks for your help so he can win this bet

 

Input

 

Input consists of several test cases. Each case contains three integer values H, Z and L, which represent the ages of Huguinho, Zezinho and Luisinho, respectively.

 

Output

 

For each test case print the name of the middle nephew in lowercase.

 

 

 

Input Samples Output Samples

5 6 7

zezinho

 

 

 

7 5 6

luisinho

 

 

 

6 7 5

huguinho

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>
int main() {

    int a,b,c;
    scanf("%d%d%d", &a,&b,&c);
    if(a > b && a < c){
        printf("huguinho\n">;
    }else if(a  <  b && a > c){
        printf("huguinho\n");
    }else if(b > a && b < c){
        printf("zezinho\n">;
    }else if(b  <  a && b > c){
        printf("zezinho\n");
    }else{
        printf("luisinho\n");
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 6 7

Output

x
+
cmd
zezinho

#2 Code Example with C++ Programming

Code - C++ Programming


#include <bits/stdc++.h>
 
using namespace std;

int main() {

    int a,b,c;
    cin >> a >> b >> c;
    if(a > b && a < c){
        printf("huguinho\n">;
    }else if(a  <  b && a > c){
        printf("huguinho\n");
    }else if(b > a && b < c){
        printf("zezinho\n">;
    }else if(b  <  a && b > c){
        printf("zezinho\n");
    }else{
        printf("luisinho\n");
    }
}

Copy The Code & Try With Live Editor

Input

x
+
cmd
5 6 7

Output

x
+
cmd
zezinho

#3 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("node:fs")

const ages = readFileSync("/dev/stdin", "utf8")
	.split(" ", 3)
	.map(age => Number.parseInt(age, 10))

function main() {
	// min and max ages
	const limits = [Math.max.apply(null, ages), Math.min.apply(null, ages)]

	const correctName = ["huguinho", "zezinho", "luisinho"].at(ages.findIndex((age) => limits.includes(age) === false))
	console.log(correctName)
}

main()
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 6 7

Output

x
+
cmd
zezinho

#4 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const numbers = lines[0].split(' ').map(Number);

const max = Math.max(...numbers);
const min = Math.min(...numbers);
const med = numbers.filter((n) => n !== max && n !== min)[0];

if (med === numbers[0]) console.log('huguinho');
else if (med === numbers[1]) console.log('zezinho');
else if (med === numbers[2]) console.log('luisinho');
Copy The Code & Try With Live Editor

Input

x
+
cmd
5 6 7

Output

x
+
cmd
zezinho

#5 Code Example with Python Programming

Code - Python Programming


H,Z,L=input().split()
A = [H, Z, L]
a = sorted(A)

if(a[1]==H):
    print("huguinho")
elif(a[1]==Z):
    print("zezinho")
elif(a[1]==L):
    print("luisinho")

Copy The Code & Try With Live Editor

Input

x
+
cmd
5 6 7

Output

x
+
cmd
zezinho
Advertisements

Demonstration


Previous
#3299 Beecrowd Online Judge Solution 3299 Small Unlucky Numbers Solution in C, C++, Java, Js and Python
Next
#3302 Beecrowd Online Judge Solution 3302 Correct Answer Solution in C, C++, Java, Js and Python