PAT B 1046 (C ++) - Long brush brother's title path

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 format:
input of the first line to a given positive integer N (≦ 100), followed by N rows, each row Huaquan a given recording format:
A call to call B B A draw stroke
wherein the call is a call for digital, 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. 9 12 is 10
. 5 10. 5 10
. 3. 5. 8 12 is
12 is 18 is 13 is. 1
. 4 16 15 12 is

Output Sample:
1 2

Problem-solving ideas: Is there a drink for each line of input statistics, the final result can be output

#include<iostream>
#include<cstdio>
#include<string>
#include<map>
#include<cmath>
using namespace std;
int main(){
	int num = 0,jiasum=0,yisum=0;
	cin >> num;
	for (int i = 0; i < num; i++){
		int jiahan = 0, jiahua = 0,yihan=0,yihua=0;
		cin >> jiahan >> jiahua >> yihan >> yihua;
		int sum = jiahan + yihan;
		if (sum == yihua && sum!=jiahua){
			jiasum++;
		}
		if (sum == jiahua && sum!=yihua){
			yisum++;
		}
	}
	cout << jiasum << " " << yisum << endl;
	return 0;
}
Published 46 original articles · won praise 0 · Views 554

Guess you like

Origin blog.csdn.net/qq_23079139/article/details/104106017