PAT Basic 1046 Guessing Game (15 points)

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 formats:

First input of the first row is given a positive integer  N ( ≤), followed by  N rows, each row Huaquan a given recording format:

甲喊 甲划 乙喊 乙划

Wherein is shouted figures are drawn numbers are positive integers not more than 100 (designated with two hands).

Output formats:

A successively output in a row, the number of cups of drink B two, with a space therebetween.

Sample input:

5
8 10 9 12
5 10 5 10
3 8 5 12
12 18 1 13
4 16 12 15

Sample output:

1 2

#include <the iostream>
 the using  namespace STD;
 int main () {
     int T, A, B, C, D, TEMP, drinkA = 0 , drinkB = 0 ; // Drink ab drink number for the 
    CIN >> T;
     the while (T - ) { 
        CIN >> >> B >> A >> C D;
         // start ref 
        TEMP = A + C; // TEMP call for recording digital sum 
        IF (TEMP TEMP = D && == B) drinkB ++! ;
         the else  IF (TEMP TEMP == D = B &&!) drinkA ++ ; 
    } 
    COUT << drinkA << "  " <<drinkB;
    system("pause");
    return 0;
}

 

 

Guess you like

Origin www.cnblogs.com/littlepage/p/11267581.html