SWUST-划拳游戏

SWUST-划拳游戏_第1张图片

代码实现如下

#include
using namespace std;
int main() {
    int A, B, n, ha = 0, hb = 0, pa, pb, pah, pbh;
    cin >> A >> B >> n;
    while (n--) {
        int flaga = 0, flagb = 0;
        cin >> pa >> pah >> pb >> pbh;
        if (pa + pb == pah) 
            flaga = 1;
        if (pa + pb == pbh) 
            flagb = 1;
        if (flaga == 1 && flagb == 0) {
            ha += 1;
        }else if (flaga == 0 && flagb == 1) {
            hb += 1;
        }
        if (ha > A) {
            cout << "A" << endl << hb << endl;
            return 0;
        }
        else if (hb > B) {
            cout << "B" << endl << ha << endl;
            return 0;
        }
    }
    return 0;
}

你可能感兴趣的:(SWUST,OJ,#期末真题/转专业题,游戏)