Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Last active December 24, 2016 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mokomokohitsuzi/53b1660815024c355f64142e88f555c1 to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/53b1660815024c355f64142e88f555c1 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習7-2
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