Competitive Programming Solutions

GitHub
back to dashboard

K. Max and Min

Codeforces - Sheet #1 (Data type - Conditions) · limit: 0.25s · memory: 64MB · view on codeforces

input

1 2 3

output

1 3
Main.java
static void solve() {

        // Write your solution here
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        min = Math.min(min, a);
        min = Math.min(min, b);
        min = Math.min(min, c);
        max = Math.max(max, a);
        max = Math.max(max, b);
        max = Math.max(max, c);
        out.print(min + " " + max);
    }