★★ Java の宿題ここで答えます Part 66 ★★ at TECH
[2ch|▼Menu]
387:デフォルトの名無しさん
08/11/14 23:07:23
>>386
ランタイムエラーやオーバーフローは気にしない
public class Q1 {
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
System.out.printf("最大値=%d, 最小値=%d, 差の絶対値=%d%n", Math.max(a, b), Math.min(a, b), Math.abs(a - b));
}
}
public class Q2 {
public static void main(String[] args) {
int s = 0;
for (String a : args) s += Integer.parseInt(a);
System.out.printf("平均=%f%n", (double)s / args.length);
}
}
public class Q3 {
public static void main(String[] args) {
int x = Integer.parseInt(args[0]);
int y = Integer.parseInt(args[1]);
int s = Math.round(Math.signum(y - x));
for (int i = x + s; i != y; i += s) System.out.println(i);
}
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

5103日前に更新/239 KB
担当:undef