pat1018:锤子剪刀布

https://www.patest.cn/contests/pat-b-practise/1018

#include "stdio.h"

int main()
{
	int i, n, kj, ky, maxj = -1, maxy = -1;
	char jia, yi;
	int j[6] = {0}, y[6] = {0};
	scanf("%d", &n);
	for(i = 0; i < n; ++i)
	{
		scanf(" %c %c", &jia, &yi);
		if((('B' == jia) && ('C' == yi)) || (('C' == jia) && ('J' == yi)) || (('J' == jia) && ('B' == yi)))
		{
			++j[0];
			++y[2];
			if('B' == jia) ++j[3];
			else if('C' == jia) ++j[4];
			else ++j[5];
		}
		else if(yi == jia)
		{
			++j[1];
			++y[1];
		}
		else
		{
			++j[2];
			++y[0];
			if('B' == yi) ++y[3];
			else if('C' == yi) ++y[4];
			else ++y[5];
		}
	}
	printf("%d %d %d\n", j[0], j[1], j[2]);
	printf("%d %d %d\n", y[0], y[1], y[2]);
	for(i = 3; i < 6; ++i)
	{
		if(maxj < j[i])
		{
			maxj = j[i];
			kj = i;
		}
		if(maxy < y[i])
		{
			maxy = y[i];
			ky = i;
		}
	}
	if(3 == kj) printf("B ");
	else if(4 == kj) printf("C ");
	else printf("J ");

	if(3 == ky) printf("B\n");
	else if(4 == ky) printf("C\n");
	else printf("J\n");

	return 0;
}


你可能感兴趣的:(c,pat)