JAVAの模範解答 1

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if ( a <= b && b <= c){
            System.out.println(a + " " + b + " " + c);
        } else if ( a <= c && c <= b){
            System.out.println(a + " " + c + " " + b);
        } else if ( b <= a && a <= c){
            System.out.println(b + " " + a + " " + c);
        } else if ( b <= c && c <= a){
            System.out.println(b + " " + c + " " + a);
        } else if ( c <= a && a <= b){
            System.out.println(c + " " + a + " " + b);
        } else if ( c <= b && b <= a){
            System.out.println(c + " " + b + " " + a);
        }
    }
}

JAVAの模範解答 2

import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int t;

        if ( a > b ){
            t = a; a = b; b = t;
        }
        if ( b > c ){
            t = b; b = c; c = t;
        }
        if ( a > b ){
            t = a; a = b; b = t;
        }
        System.out.println(a + " " + b + " " + c);
    }
}

Reference

 

オンラインジャッジではじめるC/C++プログラミング入門 (マイナビ)

AIZU ONLINE JUDGE のコース問題を題材にした解説書です。各トピックごとに C/C++ 言語の基礎的な内容を学習し、Introduction to Programming の演習問題にチャレンジしていきます。内容は敷居の高いものではなく、プログラミング初学者が取り組む例題からスタートしています。