PAT_甲级_1011 World Cup Betting (20分) (C++) 【签到题】

目录

1,题目描述

题目大意:

2,思路

3,代码【C++】


1,题目描述

Sample Input:

1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1

Sample Output:

T T W 39.31

题目大意:

题目花里胡哨的,然而主要思想很简答:只需要找出每一行数字最大值对应的字符,并记录此数字,三行过后,按公式计算即可(公式是什么意思,我也没看懂。。。但不妨碍做题)

2,思路

就是你想的那样。

3,代码【C++】

#include<iostream>
using namespace std;

int main(){
//#ifdef ONLINE_JUDGE
//#else
//    freopen("1.txt", "r", stdin);
//#endif

    float temp, max = 0.0f, ans = 1;
    char c = 'W';
    char res[3];
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0; j < 3; j++){
            cin>>temp;
            if(temp > max){
                max = temp;
                if(j == 1) c = 'T';
                else if(j == 2) c = 'L';

            }
        }
        res[i] = c;
        ans *= max;
        max = 0.0f;
        c = 'W';
    }
    cout<<res[0]<<' '<<res[1]<<' '<<res[2]<<' ';
    ans = (ans  * 0.65 - 1 ) * 2;
    printf("%.2f", ans);

    return 0;
}
发布了45 篇原创文章 · 获赞 5 · 访问量 2190

猜你喜欢

转载自blog.csdn.net/qq_41528502/article/details/104219462