## 锤子剪刀布 (20分)

``````10
C J
J B
C B
B B
B C
C C
C B
J B
B C
J J
``````

``````5 3 2
2 3 5
B B
``````

``````#include<stdio.h>
int main()
{

int i, n, max = 0, max1 = 0;
char a, b;
int p[3] = {

0}, q[2][3] = {

0};
scanf("%d",&n);
getchar();
for (i = 0; i < n; i ++)
{

scanf("%c %c",&a,&b);
getchar();
if (a == b)
p[1] ++;
else if ((a == 'J'&&b == 'B')||(a == 'B'&&b == 'C')||(a == 'C'&&b == 'J'))
p[0] ++;
else
p[2] ++;
if (a == 'J')
{

if(b == 'B')
q[0][0] ++;
if(b == 'C')
q[1][0] ++;
}
if (a == 'B')
{

if(b == 'C')
q[0][1] ++;
if(b == 'J')
q[1][1] ++;
}
if (a == 'C')
{

if(b == 'J')
q[0][2] ++;
if(b == 'B')
q[1][2] ++;
}
}
printf("%d %d %d\n",p[0],p[1],p[2]);
printf("%d %d %d\n",p[2],p[1],p[0]);
for(i = 0; i < 3; i ++)
{

if(q[0][i] > max)
max = q[0][i];
if(q[1][i] > max1)
max1 = q[1][i];
}
if(max == q[0][1])
printf("B ");
else if(max == q[0][2])
printf("C ");
else
printf("J ");
if(max1 == q[1][2])
printf("B");
else if(max1 == q[1][0])
printf("C");
else
printf("J");
return 0;
}
``````

おすすめ
ランキング
アーカイブ