L1-7 谁是赢家

思路

这题好简单,可以分析一下,没有别的情况了。

代码

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int p1,p2,c[3];
    int a=0,b=0;
    scanf("%d%d%d%d%d",&p1,&p2,&c[0],&c[1],&c[2]);
    for (int i=0;i<3;i++) {
        if (c[i]==0) {
            a++;
        }
        else {
            b++;
        }
    }
    if (p1>p2&&a) {
        printf("The winner is a: %d + %d\n",p1,a);
    }
    else if (p2>p1&&b) {
        printf("The winner is b: %d + %d\n",p2,b);
    }
    else if (a==3&&p1<p2) {
        printf("The winner is a: %d + %d\n",p1,a);
    }
    else if (b==3&&p2<p1) {
        printf("The winner is b: %d + %d\n",p2,b);
    }
    return 0;
}


posted @ 2020-02-20 18:20  xyee  阅读(250)  评论(0编辑  收藏  举报