Created
October 20, 2016 12:25
-
-
Save mokomokohitsuzi/aa09e7a3a8fd371db78c5d7c76a33b8e to your computer and use it in GitHub Desktop.
新・明解Java入門 演習3-12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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