PAT A1011 World Cup Betting(20)

AC代码

#include <cstdio>
#include <algorithm>
const int max_n = 3;
using namespace std;
/*
struct Bet {
    double W, T, L
}bet[3];

void init() {
    for(int i = 0; i < max_n; i++) {
        bet[i].W = bet[i].T = bet[i].L = 0.0;
    }
}
*/
int main() {
    #ifdef ONLINE_JUDGE
    #else
        freopen("1.txt", "r", stdin);
    #endif // ONLINE_JUDGE
    char str[] = {'W', 'T', 'L'};
    int str_record[3] = {0};
    double max_record[3] = {0.0};
    for(int i = 0; i < max_n; i++) {
        double W = 0.0, T = 0.0, L = 0.0;
        scanf("%lf%lf%lf", &W, &T, &L);
        max_record[i] = (W>T)?(W>L?W:L):(T>L?T:L); //通过三元运算符比较大小
        //printf("max_record[%d]:%lf\n", i, max_record[i]);
        double temp = max_record[i];
        //printf("temp:%lf\n", temp);
        int j = temp==W?0:(temp==T?1:(temp==L?2:-1));//通过三元运算符确定哪个概率最大
        //printf("num:%d\n", j);
        str_record[i] = j;
        max_record[i] = temp;
    }

    for(int i = 0; i < max_n; i++) {
        printf("%c ", str[str_record[i]]);
    }
    double result = 0.0;
    result = (max_record[0] * max_record[1] * max_record[2] * 0.65 - 1) * 2;//
    printf("%.2f", result);
    return 0;
}

原文地址:https://www.cnblogs.com/isChenJY/p/11267229.html

时间: 2024-08-30 10:10:05

PAT A1011 World Cup Betting(20)的相关文章

PAT A1011 World Cup Betting

PAT A1011 World Cup Betting 题目描述: With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, footbal

A1011. World Cup Betting (20)

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their

1011. World Cup Betting (20)——PAT (Advanced Level) Practise

题目信息: 1011. World Cup Betting (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing

pat1011. World Cup Betting (20)

1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battl

1011. World Cup Betting (20)

1011. World Cup Betting (20) With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football bet

Programming Ability Test学习 1011. World Cup Betting (20)

1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battl

PATA 1011 World Cup Betting (20)

1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battl

PAT (Advanced Level) Practice 1011 World Cup Betting (20 分)

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Similarly, football betting fans were putting their

PAT (Advanced Level) 1011. World Cup Betting (20)

简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> using namespace std; double a[5][5],Max[5]; double ans=1; int main() { for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) scanf(&qu