【1011】World Cup Betting (20 分)

简介: 【1011】World Cup Betting (20 分)【1011】World Cup Betting (20 分)
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>  
#include<map>
#include<vector>
#include<queue> 
using namespace std;  
找出每行的max(分别为a,b,c),最大期望收益为(a*b*c*0.65-1)*2
要用idx变量记录每行最大数字的下标,S[]={'W','T','L'}表示比赛结果使输出更方便
char S[3]={'W','T','L'};  //s[0]='W' s[1]='T'  s[2]='L'
int main(){   
  double ans=1.0,tmp,a;
  int idx; //记录每行最大数字的下标
  for(int i=0;i<3;i++){
    tmp=0.0;
    for(int j=0;j<3;j++){//寻找该行最大的数组存在于tmp
      scanf("%lf",&a);
      if(a>tmp){
        tmp=a;
        idx=j;
      }
    }
    ans *= tmp; //按公式累乘
    printf("%c ",S[idx]);  //输出对应的比赛结果
  }
  printf("%.2f",(ans*0.65 -1)*2);  //输出最大收益
  system("pause"); 
    return 0;   
}
相关文章
|
4月前
1043 输出PATest (20 分)
1043 输出PATest (20 分)
|
C++
【PAT甲级 - C++题解】1011 World Cup Betting
【PAT甲级 - C++题解】1011 World Cup Betting
56 0
World Final? World Cup (I)(模拟)
World Final? World Cup (I)(模拟)
73 0
PTA 1043 输出PATest (20 分)
给定一个长度不超过 10 4 的、仅由英文字母构成的字符串。请将字符重新调整顺序,按 PATestPATest.... 这样的顺序输出,并忽略其它字符。
72 0
L1-001 Hello World (5 分)
L1-001 Hello World (5 分)
51 0
|
C++ Python
ZZULIOJ-1097,计算平均成绩(函数专题)(Python)
ZZULIOJ-1097,计算平均成绩(函数专题)(Python)
|
机器学习/深度学习 Python
ZZULIOJ-1061,顺序输出各位数字(Python)
ZZULIOJ-1061,顺序输出各位数字(Python)
|
C++ Python
ZZULIOJ-1096,水仙花数(函数专题)(Python)
ZZULIOJ-1096,水仙花数(函数专题)(Python)