PAT (Basic Level) 1046 划拳

题意

统计俩人划拳输赢情况。

思路

水~

代码

#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	int x = 0, y = 0;
	for (int i = 0; i < n; ++i) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		bool flag1 = (b == a + c);
		bool flag2 = (d == a + c);
		if (flag1 && flag2) continue;
		if (flag1) y++;
		if (flag2) x++;
	}
	cout << x << ' ' << y << '\n';
	return 0;
} 

HINT

不定时更新更多题解,Basic Level 全部AC代码,详见 link ! ! !

发布了50 篇原创文章 · 获赞 15 · 访问量 2660

猜你喜欢

转载自blog.csdn.net/abcdefbrhdb/article/details/104594235
今日推荐