美文网首页
2019-08-07 A1011 World Cup Betti

2019-08-07 A1011 World Cup Betti

作者: JO炮 | 来源:发表于2019-08-07 21:27 被阅读0次

    也是比较简单的一道题,只不过这道题我用的方法比较啰嗦,柳神的代码则简洁很多。这是我啰嗦的代码:

    #include <iostream>
    using namespace std;
    int main() {
        int cnt;
        float w, t, l, a[3][3] = {0.0};
        float max[3] = {0.0}, maxp = 0.0;
        for(int i = 0; i < 3; i++){
            scanf("%f %f %f", &w, &t, &l);
            a[i][0] = w;
            a[i][1] = t;
            a[i][2] = l;
        }
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(a[i][j] > max[i]){
                max[i] = a[i][j];
                cnt = j;
                }
            }
            if(cnt == 0) printf("W ");
            if(cnt == 1) printf("T ");
            if(cnt == 2) printf("L ");
        }
        maxp = max[0] * max[1] * max[2] * 0.65 * 2 - 2;
        printf("%.2f", maxp);
        
        return 0;
    }
    

    柳神的思路大概就是三个数一组读入,读的过程中就找出三个数中的最大值和最大值的index,然后直接进行累乘和输出即可。

    相关文章

      网友评论

          本文标题:2019-08-07 A1011 World Cup Betti

          本文链接:https://www.haomeiwen.com/subject/ptxodctx.html