[Grade] PAT 1011 World Cup Betting (20 points)

Meaning of the questions: given three decimal places, groups of three, representing a game Shengping Fu odds bet a dollar. Output betting scheme and calculate betting two dollars expected harvest. (Multiplied odds multiplied by 0.65 minus the principal amount of two dollars)

Code:

#include<bits/stdc++.h>
using namespace std;
double a[5][5];
double mx[5];
int pos[5];
int main(){
for(int i=1;i<=3;++i){
for(int j=1;j<=3;++j){
cin>>a[i][j];
if(a[i][j]>mx[i]){
mx[i]=a[i][j];
pos[i]=j;
}
}
}
for(int i=1;i<=3;++i){
if(pos[i]==1)
cout<<"W"<<" ";
else if(pos[i]==2)
cout<<"T"<<" ";
else if(pos[i]==3)
cout<<"L"<<" ";
}
double ans=(mx[1]*mx[2]*mx[3])*0.65*2.0-2.0;
printf("%.2f",ans);
return 0;
}

 

Guess you like

Origin www.cnblogs.com/ldudxy/p/11239904.html