PAT 甲级 1011 World Cup Betting (20 分)(Java)
题目
题目链接
解法
解法一
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
List<Character> list = new ArrayList<>();
double[] d = new double[3];
double res = 1.0;
for (int i = 0; i < 3; i++) {
d[0] = sc.nextDouble();
d[1] = sc.nextDouble();
d[2] = sc.nextDouble();
if(d[0] > d[1] && d[0] > d[2]){
res *= d[0];
list.add('W');
}else if(d[1] > d[0] && d[1] > d[2]) {
res *= d[1];
list.add('T');
}else if(d[2] > d[0] && d[2] > d[1]) {
res *= d[2];
list.add('L');
}
}
res = (res * 0.65 - 1) * 2;
for (int i = 0; i < list.size(); i++) {
System.out.print(list.get(i) + " ");
}
System.out.println(String.format("%.2f", res));
}
}
|