PAT乙级 锤子剪刀布 (20)

水题

输入并统计,最后在做判断之后输出.

#include "iostream"
#include "string.h"
using namespace std;

int main()
{
	int count;
	
	int win1=0,lost1=0,band1=0;
	int win2=0,lost2=0,band2=0;
	int num1[3],num2[3];
	memset(num1,0,sizeof(num1));
	memset(num2,0,sizeof(num2));
	//1 c 2 j 3 b
	char result1,result2;
	char tempa,tempb;

	cin>>count;
	
	while(count--)
	{
		
		cin>>tempa>>tempb;

		if(tempa == tempb)
		{
			band1++;
			band2++;

		}	
		else if((tempa == 'C'&&tempb == 'J')||(tempa == 'J'&&tempb == 'B')||(tempa == 'B'&&tempb == 'C'))
		{
			if(tempa == 'C')
				num1[0]++;
			else if (tempa == 'J')
				num1[1]++;
			else if (tempa == 'B')
				num1[2]++;
			win1++;
			lost2++;
		}
		else
		{
			if(tempb == 'C')
				num2[0]++;
			else if (tempb == 'J')
				num2[1]++;
			else if (tempb == 'B')
				num2[2]++;
			lost1++;
			win2++;
		}
	}

	cout<=num1[0]&&num1[2]>=num1[1])
	{
		cout<<"B";
	}
	else if(num1[0]>=num1[1]&&num1[0]>=num1[2])
	{
		if(num1[0]==num1[2])
			cout<<"B";
		else
			cout<<"C";
	}
	else if(num1[1]>=num1[0]&&num1[1]>=num1[2])
	{
		if(num1[1]==num1[2])
			cout<<"B";
		else if(num1[1]==num1[0])
			cout<<"C";
		else
			cout<<"J";
	}

	cout<<" ";

	if(num2[2]>=num2[0]&&num2[2]>=num2[1])
	{
		cout<<"B";
	}
	else if(num2[0]>=num2[1]&&num2[0]>=num2[2])
	{
		if(num2[0]==num2[2])
			cout<<"B";
		else
			cout<<"C";
	}
	else if(num2[1]>=num2[0]&&num2[1]>=num2[2])
	{
		if(num2[1]==num2[2])
			cout<<"B";
		else if(num2[1]==num2[0])
			cout<<"C";
		else
			cout<<"J";
	}
	cout<


你可能感兴趣的:(数据结构算法学习)