PAT乙题1018. 锤子剪刀布 (20)

2018/01/25 PAT 共 1209 字,约 4 分钟
#include<iostream>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
#ifdef LOCAL
	freopen("d:\\datain.txt", "r", stdin);
	//freopen("d:\\dataout.txt", "w", stdout);
#endif LOCAL
	int n;
	cin >> n;
	char s[4] = { 'B','C','J' };
	int s1 = 0, f1 = 0, p1 = 0;
	int s2 = 0, f2 = 0, p2 = 0;
	int c1 = 0, j1 = 0, b1 = 0;
	int c2 = 0, j2 = 0, b2 = 0;
	char i1, i2;
	for (int i = 0; i < n; i++) {
		//cin >> i1 >> i2;
		scanf(" %c %c", &i1, &i2);
		//cout << i1 << " " << i2 << endl;
		if (i1 == i2) {
			p1++; p2++;
		}
		else if (i1 == 'C'&&i2 == 'J') {
			s1++; f2++; c1++;
		}
		else if (i1 == 'J'&&i2 == 'B') {
			s1++; f2++; j1++;
		}
		else if (i1 == 'B'&&i2 == 'C') {
			s1++; f2++; b1++;
		}
		else {
			f1++; s2++;
			if (i2 == 'J')
				j2++;
			else if (i2 == 'B')
				b2++;
			else
				c2++;
		}
		//cout << s1 << " " << f1 << " " << p1 << endl;
	}
	cout << s1 << " " << p1 << " " << f1 << endl;
	cout << s2 << " " << p2 << " "<<f2 << endl;
	cout << ((b1 >= c1 && b1 >= j1) ? s[0] : (c1 > b1&&c1 >= j1) ? s[1] : s[2]) << " ";
	cout << ((b2 >= c2 && b2 >= j2) ? s[0] : (c2 > b2&&c2 >= j2) ? s[1] : s[2]) << endl;
}

Search

    Table of Contents