/* ------------------------------------------------------ 3個の数字を小さい順にソート If_09_sort2 ------------------------------------------------------ */ import java.io.*; class If_09_sort2 { public static void main(String[] args) throws Exception { int a,b,c,w; BufferedReader inp=new BufferedReader (new InputStreamReader(System.in)); String keybd; System.out.print("数字を3個入れてください\n"); System.out.print("aはいくつ?"); keybd=inp.readLine(); a=Integer.parseInt(keybd); System.out.print("bはいくつ?"); keybd=inp.readLine(); b=Integer.parseInt(keybd); System.out.print("cはいくつ?"); keybd=inp.readLine(); c=Integer.parseInt(keybd); if ( a > b ) { // 変数aとbを入れ替える w=a; a=b; b=w; } if ( b > c ) { // 変数bとcを入れ替える w=b; b=c; c=w; } if ( a > b ) { // 変数aとbを入れ替える w=a; a=b; b=w; } System.out.print("\n数字を小さい順に表示します\n\n"); System.out.print(a); System.out.print(" "); System.out.print(b); System.out.print(" "); System.out.print(c); System.out.print("\n\n"); } }