当前位置:网站首页>1018 hammer scissors cloth
1018 hammer scissors cloth
2022-06-29 04:11:00 【Lele ~ll】
Everyone should be able to play “ Hammer scissors ” The game of : Both of them make gestures at the same time , The winning and losing rules are as shown in the figure :

Now give the record of the two men's confrontation , Please count the wins of both sides 、 flat 、 Negative times , And give the two sides respectively out what gesture has the greatest chance of winning .
Input format :
Enter the first 1 Line gives a positive integer N(≤105), That is, the number of confrontation between the two sides . And then N That's ok , Each line gives the message of a confrontation , Namely a 、 Gestures given by both parties at the same time .C representative “ The hammer ”、J representative “ scissors ”、B representative “ cloth ”, The first 1 Two letters represent Party A , The first 2 On behalf of Party B , There is 1 A space .
Output format :
Output No 1、2 Lines give a respectively 、 B's victory 、 flat 、 Negative times , Between the numbers 1 Space separation . The first 3 The line gives two letters , Each represents a 、 B the gesture that wins the most times , There is 1 A space . If the solution is not unique , The solution with the smallest alphabetical order is output .
sample input :
10
C J
J B
C B
B B
B C
C C
C B
J B
B C
J J
sample output :
5 3 2
2 3 5
B BThe code is as follows :
#include<stdio.h>
int main()
{
int n, j, i, k;
char a, b, f;
char ar[3] = { 0 };
char br[3] = { 0 };
scanf("%d", &n);
getchar();
int arr[3] = { 0 };
int shena[3] = { 0 };
int shenb[3] = { 0 };
for (i = 0; i < n; i++)
{
scanf("%c %c", &a, &b);
getchar();
if ((a == 'C' && b == 'J') || (a == 'J' && b == 'B') || (a == 'B' && b == 'C'))
{
arr[0]++;// -
if (a == 'C')
{
shena[0]++;
ar[0] = 'C';
}
else if (a == 'J')
{
shena[1]++;
ar[1] = 'J';
}
else
{
shena[2]++;
ar[2] = 'B';
}
}
else if ((a == 'C' && b == 'B') || (a == 'J' && b == 'C') || (a == 'B' && b == 'J'))
{
arr[1]++;// negative
if (b == 'C')
{
shenb[0]++;
br[0] = 'C';
}
else if (b == 'J')
{
shenb[1]++;
br[1] = 'J';
}
else
{
shenb[2]++;
br[2] = 'B';
}
}
else
arr[2]++;
}
printf("%d %d %d\n", arr[0], arr[2], arr[1]);
printf("%d %d %d\n", arr[1], arr[2], arr[0]);
//shena 0-C 1-J 2-B
for (i = 0; i < 3 - 1; i++)
{
for (j = 0; j < 3 - i - 1; j++)
{
if (shena[j] > shena[j + 1])
{
k = shena[j];
shena[j] = shena[j + 1];
shena[j + 1] = k;
f = ar[j];
ar[j] = ar[j + 1];
ar[j + 1] = f;
}
}
}
if (shena[0] == shena[1] && shena[1] == shena[2])
printf("B");
else if (shena[1] == shena[2])
{
if (ar[1] < ar[2])
printf("%c", ar[1]);
else
printf("%c", ar[2]);
}
else
printf("%c", ar[2]);
for (i = 0; i < 3 - 1; i++)
{
for (j = 0; j < 3 - i - 1; j++)
{
if (shenb[j] > shenb[j + 1])
{
k = shenb[j];
shenb[j] = shenb[j + 1];
shenb[j + 1] = k;
f = br[j];
br[j] = br[j + 1];
br[j + 1] = f;
}
}
}
if (shenb[0] == shenb[1] && shenb[1] == shenb[2])
printf(" B");
else if (shenb[1] == shenb[2])
{
if (br[1] < br[2])
printf(" %c", br[1]);
else
printf(" %c", br[2]);
}
else
printf(" %c", br[2]);
printf("\n");
return 0;
}边栏推荐
- Technology: how to design zkvm circuit
- Establishment of small and medium-sized enterprise network
- 干货丨微服务架构是什么?有哪些优点和不足?
- Logstash starts too slowly or even gets stuck
- mysql动态加表只能加小表,加大表跑着跑着任务就不读数据了,有什么解决办法吗
- Data collection and management [15]
- lua-protobuff emmy-lua 轮子
- 【C语言】解决 “address of stack memory associated with local variable ‘num‘ returned”
- 使用AssetStudio/UnityStudio UABE等
- Technology cloud report: side B of mixed office: how to have both security and efficiency?
猜你喜欢

Libuv library overview and comparison of libevent, libev and libuv (Reprint)

在命令行登录mysql数据库以及查看版本号

How to keep database and cache consistent

Establishment of small and medium-sized enterprise network

SEAttention 通道注意力機制

If you choose the right school, you can enter Huawei as a junior college. I wish I had known

【C语言】解决 “address of stack memory associated with local variable ‘num‘ returned”

欧拉开源社区第二届理事会第二次会议召开,新华三、超聚变和龙芯中科成为理事会成员单位

Libuv库概述及libevent、libev、libuv对比(转载)

MySQL review materials (additional) case when
随机推荐
Developer scheme · environmental monitoring equipment (Xiaoxiong school IOT development board) connected to graffiti IOT development platform
My creation anniversary
Daily practice - February 15, 2022
NotImplementedError: Could not run torchvision::nms
[WC2021] 斐波那契——数论、斐波那契数列
Call snapstateon closed sou from Oracle CDC
1018 锤子剪刀布
科班出身,结果外包都不要
Emotional changes need to be controlled
If you choose the right school, you can enter Huawei as a junior college. I wish I had known
Redis 缓存穿透、缓存击穿、缓存雪崩
Does cdc2.2.1 not support postgresql14.1? Based on the pgbouncer connection mode, with 5433
女程序员晒出5月的工资条:工资是高,但是真累,网友评论炸锅了
[C language] explain the thread recycling function pthread_ join
Draft competition process of Intelligent Vision Group
数据库和缓存如何保持一致性
New listing of operation light 3.0 -- a sincere work of self subversion across the times
Path and LD_ LIBRARY_ Example of path usage
Runtimeerror in yolox: dataloader worker (PID (s) 17724, 1364, 18928) exited unexpectedly
MySQL can only add small tables when adding tables dynamically. If you increase the size of tables, you won't read data when running tasks. Is there any solution