Tutte le sfide
Facile 0 risolte 0% di accettazione

Largest of Three

Pick the largest of three numbers without a built-in max.

Problema

Return the largest of three integers. Practice comparisons with if statements; don't use a built-in max function.

Implement largest_of_three(a, b, c).

Input

a: The first number. b: The second number. c: The third number.

Output

Return the largest value.

Vincoli

-1,000,000,000 ≤ a, b, c ≤ 1,000,000,000

Esempi

Esempio 1
Input:
a = 3
b = 9
c = 4

Output atteso:
expected = 9
Input:
long long a = 3;
long long b = 9;
long long c = 4;

Output atteso:
long long expected = 9;
Input:
long a = 3;
long b = 9;
long c = 4;

Output atteso:
long expected = 9;

Spiegazione

9 is greater than both 3 and 4.

Esempio 2
Input:
a = -5
b = -2
c = -2

Output atteso:
expected = -2
Input:
long long a = -5;
long long b = -2;
long long c = -2;

Output atteso:
long long expected = -2;
Input:
long a = -5;
long b = -2;
long c = -2;

Output atteso:
long expected = -2;

Spiegazione

-2 appears twice and is the largest value.

Riferimenti

Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.

Impara dagli altri

Soluzioni della community

Nessuna soluzione pubblicata. Risolvi questa sfida per condividere la prima.