Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Created October 20, 2016 12:25
Show Gist options
  • Save mokomokohitsuzi/aa09e7a3a8fd371db78c5d7c76a33b8e to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/aa09e7a3a8fd371db78c5d7c76a33b8e to your computer and use it in GitHub Desktop.
新・明解Java入門 演習3-12
import java.util.Scanner;
public class En3_12 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.print("整数値A:");
int a = stdIn.nextInt();
System.out.print("整数値B:");
int b = stdIn.nextInt();
System.out.print("整数値C:");
int c = stdIn.nextInt();
// minにaを代入する。
int min = a;
// bがminより小さい場合、minにbを代入する。
if (b < min) {
min = b;
}
// cがminより小さい場合、minにcを代入する。
if (c < min) {
min = c;
}
System.out.println("最小値は" + min + "です。");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment