当前位置:网站首页>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;
}边栏推荐
- Data collection and management [15]
- Pytorch read / write file
- Rapid development project -vscode plug-in
- 树莓派用VNC Viewer方式远程连接
- I came from a major, so I didn't want to outsource
- Draft competition process of Intelligent Vision Group
- 云原生周报 | Grafana 9正式发布;云原生词汇表中文版现已上线
- 使用AssetStudio/UnityStudio UABE等
- 【FPGA+sin】基于DDS(直接数字合成)的正弦信号发生器模块FPGA实现
- 【布里渊现象】光纤布里渊温度和应变分布同时测量系统研究
猜你喜欢

Zhai Jia: from technical engineer to open source entrepreneur of "net red"

How to back up all data on Apple mobile phone in 2 steps (free)

Runtimeerror in yolox: dataloader worker (PID (s) 17724, 1364, 18928) exited unexpectedly

c语言 --- 分支结构

C language -- branch structure

【C语言】解决 “address of stack memory associated with local variable ‘num‘ returned”
![[C language] explain the thread exit function pthread_ exit](/img/fb/96db1c712370dbb216a06440ecdc5e.png)
[C language] explain the thread exit function pthread_ exit

Error accessing database
![[fpga+sin] FPGA implementation of sinusoidal signal generator module based on DDS (direct digital synthesis)](/img/7d/d507d435fe97de005e20560fd6ba35.png)
[fpga+sin] FPGA implementation of sinusoidal signal generator module based on DDS (direct digital synthesis)

女程序员晒出5月的工资条:工资是高,但是真累,网友评论炸锅了
随机推荐
[C language] explain the thread exit function pthread_ exit
moudo网络库剖析
NotImplementedError: Could not run torchvision::nms
云主机mysql在本地电脑连接不上
The second meeting of the Second Council of Euler open source community was held, and Xinhua III, hyperfusion and Godson Zhongke became members of the Council
Mécanisme d'attention du canal de fixation
[Brillouin phenomenon] Study on simultaneous measurement system of Brillouin temperature and strain distribution in optical fiber
MySQL复习资料(附加)case when
Why is the test post a giant pit? The 8-year-old tester told you not to be fooled
不使用union实现Mysql 列转行
Log in to the MySQL database and view the version number on the command line
Pytorch read / write file
Ask the handler about the memory leak scenario in the interview. Don't just know static internal classes & weak references!
HCIE-Security Day41:理论学习:信息收集与网络探测
yolox出现 RuntimeError: DataLoader worker (pid(s) 17724, 1364, 18928) exited unexpectedly
[FPGA mathematical formula] use FPGA to realize common mathematical formulas
剑指 Offer II 040. 矩阵中最大的矩形
Anaconda's own Spyder editor starts with an error
Nuxt - 每个页面单独设置 SEO 相关标签及网页标题、图标等(页面配置 head)
Web crawler knowledge day04