くだすれJava(超初心 ..
862:デフォルトの名無しさん
08/04/14 00:02:54
キーボードから読み込んだ三つの整数値の中央値を求めて表示するプログラムです。
import java.util.Scanner;
class ex0313 {
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();
int mid = a;
if (a > b) {
if (b > c)
mid = b;
else if (c < a)
mid = c;
} else {
if (a > c)
mid = a;
else if (c > b)
mid = b;
else
mid = c;
}
System.out.println("中央値は" + mid + "です。");
}
}
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4024日前に更新/302 KB
担当:undef