Maximum of two integer numbers P57846


Statement
 

pdf   zip   main.cc   main.c   main.java   main.py

thehtml

Write a function that returns the maximum of two given integer numbers a and b.

Interface

C++
int max2(int a, int b);
C
int max2(int a, int b);
Java
public static int max2(int a, int b);
Python
max2(a, b) # returns int
MyPy Python
max2(a: int, b: int) -> int

Observation You only need to submit the required procedure; your main program will be ignored.

Public test cases
  • Input/Output

    max2(123, 666) → 666
    max2(3, 4) → 4
    max2(2, 2) → 2
    max2(-1, 0) → 0
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C C++ Java Python
    User solutions
    C C++ Java Python