Last active
December 24, 2016 13:49
-
-
Save mokomokohitsuzi/53b1660815024c355f64142e88f555c1 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習7-2
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 En07_02 { | |
public static void main(String[] args) { | |
Scanner stdIn = new Scanner(System.in); | |
System.out.println("3つの整数値を入力して下さい"); | |
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の実行 | |
int min = min(a, b, c); | |
System.out.printf("最小値は%dです。", min); | |
} | |
// 最小値minを求めるメソッド | |
static int min(int a, int b, int c) { | |
int min = a; | |
if (min > b) { | |
min = b; | |
} | |
if (min > c) { | |
min = c; | |
} | |
return min; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment