Guessing Game PAT B -1046 (15 minutes)

Click on the link full solution summary PAT B -AC

Title:
Finger 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 Huaquan a given recording format:

Jiahanjiahua Yihanyihua

Where the call is shouted figure, it is planning 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 10 9 12
5 10 5 10
3 8 5 12
12 18 1 13
4 16 12 15

Sample output:

1 2

My code:

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstring>
#include<sstream>
using namespace std;
//有的时候题目是一起做的,所以会有不需要的头文件

int main()
{
    int N;
    scanf("%d\n",&N);
    int jia=0,yi=0;
    for(int i=0;i<N;i++)
    {
        int a,b,c,d;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        if(b==a+c && d!=a+c)yi++;
        else if(b!=a+c && d==a+c)jia++;
    }
    cout<<jia<<" "<<yi;
    return 0;
}

Published 82 original articles · won praise 1 · views 1690

Guess you like

Origin blog.csdn.net/qq_34451909/article/details/104800655