1046. Huaquan (15) time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen, Yue
Huaquan is an interesting part of the ancient Chinese wine culture. Two people Huaquan on the table are: Each person's mouth shout out a number, at the same time by hand to figure out a number. If the figure is equal to the number of two people shouting the sum of the numbers, who wins, the loser penalty a glass of wine. Both win or lose with each other and continue the next round until the only winner appears.
Here are the Huaquan records for both A and B, please count how many glasses of wine they drank last.
Input format:
Enter the first line first to give a positive integer n (<=100), followed by n lines, each row gives a round of Huaquan records, in the form of:
A shout a row B shout B row
The "shout" is the number that is shouted out, and the number of "strokes" is a positive integer of not more than 100 (two hand strokes).
Output format:
In one row successively output A, B two people drink the number of cups, in the meantime separated by a space.
Input Sample:
58 10 9 125 10 5 103 8 5 1212 18 1 134 16 12 15
Sample output:
1 2
The problem is also relatively simple, the only thing to note is that a win, b corresponding wine to add a cup
1 //1046.cpp: Defines the entry point of the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6 7 using namespacestd;8 9 classGameTen { One Public: A inta[4]; - }; - the intMain () - { - intn,x=0, y=0; - +CIN >>N; - +Game *p =NewGame[n]; A at for(inti =0; i < N; i++) - { -CIN >> p[i].a[0] >> p[i].a[1] >> p[i].a[2] >> p[i].a[3]; - - if((p[i].a[0] + p[i].a[2]) = = p[i].a[1] && (p[i].a[0] + p[i].a[2])! = p[i].a[3]) -y++; in Else if((p[i].a[0] + p[i].a[2]) = = p[i].a[3] && (p[i].a[0] + p[i].a[2])! = p[i].a[1]) -X + +; to Else + Continue; - } the *cout << x <<" "<<y; $ Panax Notoginseng Delete[] p; - the return 0; +}
PAT B 1046 Huaquan (+) C + + Edition