PAT 1011. World Cup Betting (20)
http://www.patest.cn/contests/pat-a-practise/1011
1 #include<stdio.h> 2 #include<math.h> 3 4 const int eps = 1e-9; 5 6 char bet[] = {'W', 'T', 'L'}; 7 double odds[3][3]; 8 int result[3]; 9 int cmp(double a, double b) { 10 if (a - b < eps && a - b > -eps) { 11 return 0; 12 } 13 return a > b ? 1 : -1; 14 } 15 16 int main() { 17 for (int i = 0; i < 3; ++i) { 18 double max_odd = -eps; 19 int index = 0; 20 for (int j = 0; j < 3; ++j) { 21 scanf("%lf", &odds[i][j]); 22 if (cmp(odds[i][j], max_odd) > 0) { 23 max_odd = odds[i][j]; 24 result[i] = j; 25 } 26 } 27 } 28 double res = 1.0; 29 for (int i = 0; i < 3; ++i){ 30 res *= odds[i][result[i]]; 31 } 32 res = (res * 0.65 -1) * 2; 33 printf("%c %c %c %.2lf\n", bet[result[0]], bet[result[1]], bet[result[2]], res); 34 return 0; 35 }

浙公网安备 33010602011771号