08/06/18 18:19:48
>>201
public class GameResult {
public static void main(String[] args) {
// {{一位の勝ち数,負け数}, ... ,{六位の勝ち数,負け数}}
int[][] winlose = {{34, 17}, {28, 22}, {23, 25}, {25, 28}, {22, 28}, {15, 35}};
if (args.length == 2) {
try {
int teamA = Integer.parseInt(args[0]);
int teamB = Integer.parseInt(args[1]);
if (teamA < 1 || teamA > 6 || teamB < 1 || teamB > 6) throw new NumberFormatException();
if (teamA > teamB) { int tmp = teamA; teamA = teamB; teamB = tmp; }
System.out.println(teamA + "位と" + teamB + "位のゲーム差は" +
((winlose[teamA-1][0] - winlose[teamA-1][1]) - (winlose[teamB-1][0] - winlose[teamB-1][1])) / 2.);
} catch (NumberFormatException e) {
System.err.println("1から6までの整数を指定してください");
return;
}
} else {
System.err.println("usage: java GameResult 順位 順位");
}
}
}