PAT 1011 World Cup Betting (20分)

Topic link: click here

Question: Give three numbers in each line, find the maximum number in each line respectively, and then substitute the formula to calculate the final result, accurate to two decimal places.

Idea: as the title.

AC code:

#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    
    
    double ans = 1;
    for(int i = 0; i < 3; i++)
    {
    
    
        double a, b, c;
        scanf("%lf%lf%lf", &a, &b, &c);
        
        double t = max(a, max(b, c));
        
        if(t == a)  printf("W ");
        else if(t == b) printf("T ");
        else    printf("L ");
        
        ans *= t;
    }
    
    printf("%.2f\n", (ans * 0.65 - 1) * 2);
    
    return 0;
}

The WeChat public account "Algorithm Competition Job Search" is dedicated to explaining in detail the algorithm principles and templates involved in the competition and job search. Welcome to pay attention and communicate and progress together!

Guess you like

Origin blog.csdn.net/qq_42815188/article/details/109005319