[PAT B1046] Guessing Game

[PAT B1046] Guessing Game

Guessing Game is an interesting part of the ancient Chinese wine culture. Finger Guessing Game two of wine on the table method is: the mouth of a digital person shouted, while a hand than to draw a number. If the ratio figures who draw is exactly equal to the sum of the two numbers shouted, whoever wins, the loser penalty of one glass of wine. Both of them win or lose with the two proceed to the next round until only the winner appears.
Here are A, B two Guessing Game record, you count them separately how much to drink last glass of wine.
Input format:
input of the first line to a given positive integer N (<= 100), followed by N rows, each row gives a Guessing Game records, the format is:
A draw call A call B Plan B
where "call" is digital shouted, "plan" is to draw figures are positive integers no more than 100 (designated with two hands).
Output format:
in line successively output A, B two drinking cup number, with a space therebetween.
Sample input:
. 5
. 8. 9 12 is 10
. 5 10. 5 10
. 3. 5. 8 12 is
12 is 18 is 13 is. 1
. 4 16 12 is 15
sample output:
12

#include <stdio.h>

int main() {
    int sum, a1, a2, b1, b2, faila = 0, failb = 0;

    scanf("%d", &sum);
    while (sum--) {
        scanf("%d%d%d%d", &a1, &a2, &b1, &b2);
        if (a2 == a1 + b1 && b2 != a1 + b1) {
            failb++;
        } else if (a2 != a1 + b1 && b2 == a1 + b1) {
            faila++;
        }
    }
    printf("%d %d", faila, failb);

    return 0;
}

/*测试数据
5
8 10 9 12
5 10 5 10
3 8 5 12
12 18 1 13
4 16 12 15
 *
 * */

Test Results:
Here Insert Picture Description

Published 33 original articles · won praise 1 · views 4157

Guess you like

Origin blog.csdn.net/qq_39827677/article/details/103855236