大家应该都会玩“锤子剪刀布”的游戏:
现给出两人的交锋记录,请统计双方的胜、平、负次数,并且给出双方分别出什么手势的胜算最大。
输入第1行给出正整数N(<=105),即双方交锋的次数。随后N行,每行给出一次交锋的信息,即甲、乙双方同时给出的的手势。C代表“锤子”、J代表“剪刀”、B代
表“布”,第1个字母代表甲方,第2个代表乙方,中间有1个空格。
输出第1、2行分别给出甲、乙的胜、平、负次数,数字间以1个空格分隔。第3行给出两个字母,分别代表甲、乙获胜次数最多的手势,中间有1个空格。如果解不唯
一,则输出按字母序最小的解。
10<br/>C J<br/>J B<br/>C B<br/>B B<br/>B C<br/>C C<br/>C B<br/>J B<br/>B C<br/>J J
5 3 2<br/>2 3 5<br/>B B
import java.util.Map; import java.util.Scanner; import java.util.TreeMap; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int n = sc.nextInt(); int v = 0; int f = 0; Map<Character, Integer> mapA = new TreeMap<>(); Map<Character, Integer> mapB = new TreeMap<>(); for (int i = 0; i < n; i++) { char a = sc.next().charAt(0); char b = sc.next().charAt(0); int re = match(a, b); if (re == 1) { v++; if (mapA.containsKey(a)) { mapA.put(a, mapA.get(a) + 1); } else { mapA.put(a, 1); } } else if (re == -1) { f++; if (mapB.containsKey(b)) { mapB.put(b, mapB.get(b) + 1); } else { mapB.put(b, 1); } } } System.out.println(v + " " + (n - v - f) + " " + f); System.out.println(f + " " + (n - v - f) + " " + v); int max = 0; for (Map.Entry<Character, Integer> m : mapA.entrySet()) { if (m.getValue() > max) { max = m.getValue(); } } if (max == 0) { System.out.print("B"); } else { for (Map.Entry<Character, Integer> m : mapA.entrySet()) { if (m.getValue() == max) { System.out.print(m.getKey()); break; } } } max = 0; System.out.print(" "); for (Map.Entry<Character, Integer> m : mapB.entrySet()) { if (m.getValue() > max) { max = m.getValue(); } } if (max == 0) { System.out.print("B"); } else { for (Map.Entry<Character, Integer> m : mapB.entrySet()) { if (m.getValue() == max) { System.out.print(m.getKey()); break; } } } } } public static int match(char a, char b) { if (a == b) { return 0; } else if ((a == 'C' && b == 'J') || (a == 'J' && b == 'B') || (a == 'B' && b == 'C')) { return 1; } else { return -1; } } }
win, lose, tie = 0, 0, 0 #甲的勝、負、平次數
Jia, Yi = [0, 0, 0], [0, 0, 0] # B C J count #甲乙勝時出的手勢記錄
num = int(input())
for i in range(num):
string = input()
if string == "C J":
win += 1
Jia[1] += 1
elif string == "J C":
lose += 1
Yi[1] += 1
elif string == "C B":
lose += 1
Yi[0] += 1
elif string == "B C":
win += 1
Jia[0] += 2
elif string == "B J":
lose += 1
Yi[2] += 1
elif string == "J B":
win += 1
Jia[2] += 1
else: # there is a tie
tie += 1
print(win, tie, lose)
print(lose, tie, win)
print("BCJ"[Jia.index(max(Jia))], "BCJ"[Yi.index(max(Yi))])
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int[] js = new int[3]; int jf = 0; int[] ys = new int[3]; int yf = 0; int p = 0; while(N--!=0){ int j = convert(in.next()); int y = convert(in.next()); if(j==y) p++; else if(judge(j, y)){ //甲赢 js[j]++; yf++; }else{ ys[y]++; jf++; } } System.out.println(yf+" "+p+" "+jf); System.out.println(jf+" "+p+" "+yf); System.out.println(getResult(js)+" "+getResult(ys)); } private static int convert(String s){ if(s.equals("B")) return 0; if(s.equals("C")) return 1; return 2;// J } private static boolean judge(int j,int y){ if(j==2&&y==0) return true; else if(j>y) return false; return true; } private static String getResult(int[] a){ int max = a[0]; int index = 0; for(int i = 1;i<a.length;i++){ if(a[i]>max){ max = a[i]; index = i; } } return index==0?"B":index==1?"C":"J"; } }
//记为ab两人 a胜利的情况为:CJ、BC、JB。b胜利的情况为:JC、CB、BJ。 //根据两人胜利的情况分别统计出两人胜利的次数。平局次数 = 总场数-a胜利-b胜利。 // 用LinkedHashMap记录下ab胜利使用次数的情况。输出胜利次数最多使用情况,如果相同按字母顺序输出。 //会有三种极端情况 //情况一二:ab两人中一人全胜。举例:若a全胜且使用次数最多为C则此时b虽然全输,但是应该输出B //因为题目描述为:双方分别出什么手势胜算最大。 //情况三:ab全平。此时胜算最大无输出,(牛客应该没有情况三的用例) import java.util.*; public class Main { private static int winA = 0; private static int winB = 0; private static HashMap<Character,Integer> A = new LinkedHashMap<Character,Integer>(); private static HashMap<Character,Integer> B = new LinkedHashMap<Character,Integer>(); public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { int n = sc.nextInt(); int count = n; sc.nextLine(); while(count-- > 0) { String[] str = sc.nextLine().split(" "); StringBuffer sb = new StringBuffer(); for(String s : str) { sb.append(s); } Cjb(sb.toString()); } int peace = n-winA-winB; System.out.println(winA+" "+peace+" "+winB); System.out.println(winB+" "+peace+" "+winA); if(A.size() != 0 && B.size() != 0) { System.out.println(Mvp(A)+" "+Mvp(B)); } if(A.size() == 0 && B.size() != 0) { char a = (Mvp(B) == 'B') ? 'J' :((Mvp(B) == 'C') ? 'B' : 'C'); System.out.println(a+" "+Mvp(B)); } if(A.size() != 0 && B.size() == 0) { char b = (Mvp(A) == 'B') ? 'J' :((Mvp(A) == 'C') ? 'B' : 'C'); System.out.println(Mvp(A)+" "+b); } } } private static char Mvp(HashMap<Character,Integer> map) { Set<Character> set = map.keySet(); int tmp = 0; char ret = 'Z'; for(char c : set) { if(tmp <= map.get(c)) { tmp = map.get(c); if(ret > c) { ret = c; } } } return ret; } private static void Cjb(String s) { if(s.equals("CJ") || s.equals("JB") || s.equals("BC")) { winA++; A.put(s.charAt(0),A.containsKey(s.charAt(0)) ? A.get(s.charAt(0))+1 : 1); } if(s.equals("JC") || s.equals("BJ") || s.equals("CB")) { winB++; B.put(s.charAt(1),B.containsKey(s.charAt(1)) ? B.get(s.charAt(1))+1 : 1); } } }
#include <iostream> using namespace std; /* C > J J > B B > C B > C > J > B */ int main(int argc, char** argv) { int num; // 0:胜, 1:平, 2:负, 3:B, 4:C, 5:J int jarr[6] = {0}, yarr[6] = {0}; char ja, yi; cin >> num; while(num--){ // 求获胜次数获胜字母的次数 cin >> ja >> yi; if(ja == 'B' && yi == 'C'){ jarr[0]++; yarr[2]++; jarr[3]++; }else if(ja == 'C' && yi == 'B'){ jarr[2]++; yarr[0]++; yarr[3]++; }else if(ja == 'J' && yi == 'B'){ jarr[0]++; yarr[2]++; jarr[5]++; }else if(ja == 'B' && yi == 'J'){ jarr[2]++; yarr[0]++; yarr[5]++; }else if(ja == 'C' && yi == 'J'){ jarr[0]++; yarr[2]++; jarr[4]++; }else if(ja == 'J' && yi == 'C'){ jarr[2]++; yarr[0]++; yarr[4]++; }else{ jarr[1]++; yarr[1]++; } } ja = jarr[4] >= jarr[5] ? 'C' : 'J'; ja = jarr[3] >= jarr[4] ? 'B' : ja; yi = yarr[4] >= yarr[5] ? 'C' : 'J'; yi = yarr[3] >= yarr[4] ? 'B' : yi; for(int i = 0; i < 3; i++){ cout << jarr[i]; if(i!=2) cout << " "; } cout << endl; for(int i = 0; i < 3; i++){ cout << yarr[i]; if(i!=2) cout << " "; } cout << endl; cout << ja << " " << yi; return 0; }
//锤子剪刀布 int main() { int n; cin >> n; int p1 = 0, p2 = 0, p3 = 0; int q1 = 0, q2 = 0, q3 = 0; int equ = 0; for (int i = 0; i < n; i++) { char a, b; cin >> a >> b; if (a == 'C'&&b == 'J') p1++; else if (a == 'C'&&b == 'B') q3++; else if (a == 'C'&&b == 'C') equ++; else if (a == 'J'&&b == 'J') equ++; else if (a == 'J'&&b == 'B') p2++; else if (a == 'J'&&b == 'C') q1++; else if (a == 'B'&&b == 'J') q2++; else if (a == 'B'&&b == 'B') equ++; else if (a == 'B'&&b == 'C') p3++; } int pmax = p3, qmax = q3; if (pmax < p1) pmax = p2; if (pmax < p2) pmax = p1; if (qmax < q1) qmax = q2; if (qmax < q2) qmax = q1; cout << p1 + p2 + p3 << ' ' << equ << ' ' << q1 + q2 + q3 << endl; cout << q1 + q2 + q3 << ' ' << equ << ' ' << p1 + p2 + p3 << endl; if (pmax == p3)cout << 'B'; else if (pmax == p1)cout << 'C'; else cout << 'J'; cout << ' '; if (qmax == q3)cout << 'B'; else if (qmax == q1)cout << 'C'; else cout << 'J'; cout << endl; return 0; }
/* 甲胜利有3种情况 C J J B B C 乙胜利反之 J C B J C B 此题在输入时判断次数,则不需要开数组 求出甲胜利、平局的次数和甲、乙出锤、剪、布胜利的次数即可 */ #include<iostream> using namespace std; char jia,yi; int times; int jiaWin=0,Ping=0; int jiaChui=0,jiaBu=0,jiaJian=0; int yiChui=0,yiBu=0,yiJian=0; int i; int main(){ cin>>times; for(i=0;i<times;i++){ cin>>jia>>yi; if(jia=='C'&&yi=='J'){ jiaWin++; jiaChui++; }else if(jia=='J'&&yi=='B'){ jiaWin++; jiaJian++; }else if(jia=='B'&&yi=='C'){ jiaWin++; jiaBu++; }else if(jia==yi)Ping++; else if(yi=='C'&&jia=='J')yiChui++; else if(yi=='J'&&jia=='B')yiJian++; else if(yi=='B'&&jia=='C')yiBu++; } cout<<jiaWin<<" "<<Ping<<" "<<times-Ping-jiaWin<<endl <<times-Ping-jiaWin<<" "<<Ping<<" "<<jiaWin<<endl; if(jiaBu>=jiaChui&&jiaBu>=jiaJian)cout<<"B "; else if(jiaChui>=jiaJian&&jiaChui>jiaBu)cout<<"C "; else cout<<"J "; if(yiBu>=yiChui&&yiBu>=yiJian)cout<<"B"; else if(yiChui>=yiJian&&yiChui>yiBu)cout<<"C"; else cout<<"J"; return 0; }
#include <iostream> using namespace std; struct Caiquan { int jia_win=0; int jia_lose=0; int tie=0; int yi_win=0; int yi_lose=0; int jia_J=0; int jia_C=0; int jia_B=0; int yi_J=0; int yi_C=0; int yi_B=0; }caiquan; int main() { int N,i; char j,y; cin>>N; for(i=0;i<N;i++) { cin>>j; getchar(); cin>>y; if((j=='J'&&y=='J')||(j=='C'&&y=='C')||(j=='B'&&y=='B')) { caiquan.tie+=1; } else if(j=='J'&&y=='B') { caiquan.jia_win+=1; caiquan.yi_lose+=1; caiquan.jia_J+=1; } else if(j=='C'&&y=='J') { caiquan.jia_win+=1; caiquan.yi_lose+=1; caiquan.jia_C+=1; } else if(j=='B'&&y=='C') { caiquan.jia_win+=1; caiquan.yi_lose+=1; caiquan.jia_B+=1; } else if(y=='J'&&j=='B') { caiquan.jia_lose+=1; caiquan.yi_win+=1; caiquan.yi_J+=1; } else if(y=='C'&&j=='J') { caiquan.jia_lose+=1; caiquan.yi_win+=1; caiquan.yi_C+=1; } else if(y=='B'&&j=='C') { caiquan.jia_lose+=1; caiquan.yi_win+=1; caiquan.yi_B+=1; } } cout<<caiquan.jia_win<<" "<<caiquan.tie<<" "<<caiquan.jia_lose<<endl; cout<<caiquan.yi_win<<" "<<caiquan.tie<<" "<<caiquan.yi_lose<<endl; if(caiquan.jia_B>=caiquan.jia_C&&caiquan.jia_B>=caiquan.jia_J)cout<<"B "; else if(caiquan.jia_C>caiquan.jia_B&&caiquan.jia_C>=caiquan.jia_J)cout<<"C "; else if(caiquan.jia_J>caiquan.jia_B&&caiquan.jia_J>caiquan.jia_C)cout<<"J "; if(caiquan.yi_B>=caiquan.yi_C&&caiquan.yi_B>=caiquan.yi_J)cout<<"B"; else if(caiquan.yi_C>caiquan.yi_B&&caiquan.yi_C>=caiquan.yi_J)cout<<"C"; else if(caiquan.yi_J>caiquan.yi_B&&caiquan.yi_J>caiquan.yi_C)cout<<"J"; }
//// p_1008.cpp// PAT_basic_level//// Created by 李嘉宁 on 2018/4/19.// Copyright © 2018年 李嘉宁. All rights reserved.//#include <iostream>using namespace std;intmain(){ints = 0, p = 0, f = 0;intc1 = 0, j1 = 0, b1 = 0;intc2 = 0, j2 = 0, b2 = 0;intN = 0;charjia[105], yi[105]; // 考虑过二维数组cin >> N;for(inti = 0; i < N; i++){cin >> jia[i] >> yi[i];if(jia[i] == 'C'&& yi[i] == 'J') // 考虑过C\J\B 之间的规律{s++;c1++;}elseif(jia[i] == 'J'&& yi[i] == 'B'){s++;j1++;}elseif(jia[i] == 'B'&& yi[i] == 'C'){s++;b1++;}elseif((jia[i] == 'C'&& yi[i] == 'C') || (jia[i] == 'J'&& yi[i] == 'J') || (jia[i] == 'B'&& yi[i] == 'B')){p++;}elseif(jia[i] == 'C'&& yi[i] == 'B'){f++;b2++;}elseif(jia[i] == 'J'&& yi[i] == 'C'){f++;c2++;}elseif(jia[i] == 'B'&& yi[i] == 'J'){f++;j2++;}}cout << s << ' '<< p << ' '<< f << endl;cout << f << ' '<< p << ' '<< s << endl;cout << ((((b1 >= c1) ? b1 : c1) >= j1) ? ((b1 >= c1) ? 'B': 'C') : 'J') << ' '<< ((((b2 >= c2) ? b2 : c2) >= j2) ? ((b2 >= c2) ? 'B': 'C') : 'J');return0;}
j_p = 0 j_s_c, j_s_j, j_s_b = 0, 0, 0 y_p = 0 y_s_c, y_s_j, y_s_b = 0, 0, 0 def most_win(b, c, j): if b == max(b, c, j): return 'B' elif c == max(b, c, j): return 'C' elif j == max(b, c, j): return 'J' n = int(input()) for i in range(n): j, y = input().split() if j == y: j_p += 1 y_p += 1 elif j == 'C' and y == 'J': j_s_c += 1 elif j == 'J' and y == 'B': j_s_j += 1 elif j == 'B' and y == 'C': j_s_b += 1 elif y == 'B' and j == 'C': y_s_b += 1 elif y == 'C' and j == 'J': y_s_c += 1 elif y == 'J' and j == 'B': y_s_j += 1 j_s = j_s_b + j_s_c + j_s_j j_f = n - j_p - j_s y_s = y_s_b + y_s_c + y_s_j y_f = n - y_p - y_s j_s_most = most_win(j_s_b, j_s_c, j_s_j) y_s_most = most_win(y_s_b, y_s_c, y_s_j) print(j_s, j_p, j_f) print(y_s, y_p, y_f) print(j_s_most, y_s_most)
#include <iostream>
using namespace std;
int compare(char a,char b)
{
if((a=='B'&&b=='C')||(a=='C'&&b=='J')||(a=='J'&&b=='B'))
return 1;//a获胜
if((a=='B'&&b=='B')||(a=='C'&&b=='C')||(a=='J'&&b=='J'))
return 0;//平
if((a=='C'&&b=='B')||(a=='J'&&b=='C')||(a=='B'&&b=='J'))
return -1;//b获胜
return 0;
}
int judge(char a)
{
if(a=='B')
return 1;
if(a=='C')
return 2;
if(a=='J')
return 3;
return 0;
}
char max1(int b,int c,int j)
{
if(b!=c&&b!=j&&c!=j){
if(b>c&&b>j)
return 'B';
if(c>b&&c>j)
return 'C';
if(j>b&&j>c)
return 'J';
}else{
if(b==c&&b>j)
return 'B';
if(b==c&&b<j)
return 'J';
if(c==j&&c>b)
return 'C';
if(c==j&&c<b)
return 'B';
if(b==j&&b>c)
return 'B';
if(b==j&&b<c)
return 'C';
if(b==j&&c==j&&b==c)
return 'B';
}
return 'A';
}
int main()
{
int count1,count2,count3,n,i,c1,j1,b1,b2,c2,j2;
count1=count2=count3=0;
c1=j1=b1=b2=c2=j2=0;
char a,b;
cin >> n;
for(i=0;i<n;i++){
cin >> a >> b;
if(compare(a,b)==1){
count1++;
if(judge(a)==1)
b1++;
if(judge(a)==2)
c1++;
if(judge(a)==3)
j1++;
}
if(compare(a,b)==0)
count2++;
if(compare(a,b)==-1){
count3++;
if(judge(b)==1)
b2++;
if(judge(b)==2)
c2++;
if(judge(b)==3)
j2++;
}
}
//cout << b1 << c1 << j1 <<endl;
// cout << b2 << c2 << j2 <<endl;
cout << count1 << ' ' << count2 << ' ' << count3 << endl;
cout << count3 << ' ' << count2 << ' ' << count1 << endl;
cout << max1(b1,c1,j1) << ' ' << max1(b2,c2,j2) << endl;
return 0;
}
#encoding:utf-8 #C:锤子,J:剪刀,B:布 # c>j,j>b,b>c;a1,a2列表作为优势列表;r1,r2作为胜负结果列表(胜,平,负) a1 = {'J':0,'C':0,'B':0} a2 = {'J':0,'C':0,'B':0} r1 = [0,0,0] r2 = [0,0,0] tmp = '' y1=y2='' times = int(raw_input()) if times: for v in range(times): t1,t2 = raw_input().split(' ') if t1 == 'C' and t2 == 'J': r1[0]+=1 r2[2]+=1 a1['C']+=1 # a2['J']+=1 elif t1 == 'J' and t2 =='C': r2[0]+=1 r1[2]+=1 a2['C']+=1 # a1['J']+=1 elif t1 == 'J' and t2 == 'B': r1[0]+=1 r2[2]+=1 a1['J']+=1 elif t1 =='B' and t2 == 'J': r2[0]+=1 r1[2]+=1 a2['J'] +=1 elif t1 == 'B' and t2 =='C': r1[0]+=1 r2[2]+=1 a1['B']+=1 elif t1 == 'C' and t2 == 'B': r2[0]+=1 r1[2]+=1 a2['B']+=1 else: r1[1]+=1 r2[1]+=1 a1 = sorted(a1.iteritems(),key=lambda x:x,reverse=True) a2 = sorted(a2.iteritems(),key=lambda x:x,reverse=True) for k,v in a1: if v == 0: continue v = tmp y1 = k if v>tmp: c = tmp tmp = v v = c y1 = k for k,v in a2: if v == 0: continue v = tmp y2 = k if v>tmp: c = tmp tmp = v v = c y2 = k if not y1: y1 = 'B' if not y2: y2 = 'B' print '%d %d %d' % tuple(r1) print '%d %d %d' % tuple(r2) print '%s %s' % (y1,y2)
import java.util.Scanner; public class Main { /* * 数组存储,做差求值,下标输出 */ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] num = new int[3];// num[0]:甲胜 num[1]:平局 num[2]:乙胜 char[] b = { 'B', 'C', 'J' };// 哈哈,正好为字母表顺序存储 int[][] bt = new int[3][2];// bt[i][0]:甲BCJ胜的次数 乙同理 char[] w = new char[2]; for (int i = 0; i < n; i++) { char t1 = in.next().charAt(0); char t2 = in.next().charAt(0); int te1 = -10, te2 = -10; for (int j = 0; j < b.length; j++) { if (t1 == b[j]) te1 = j; if (t2 == b[j]) te2 = j; } switch (te1 - te2) { case -1:// 甲胜 case 2: num[0]++; bt[te1][0]++; break; case 1:// 乙胜 case -2: num[2]++; bt[te2][1]++; break; default:// 平局 num[1]++; break; } } System.out.printf("%d %d %d\n", num[0], num[1], num[2]); System.out.printf("%d %d %d\n", num[2], num[1], num[0]); for (int j = 0; j < 2; j++) { int max = bt[0][j]; int ww = 0; for (int i = 1; i < 3; i++) { if (bt[i][j] > max) { max = bt[i][j]; ww = i; } } System.out.print(b[ww]); if (j != 1) System.out.print(" "); } } }
#include<iostream>using namespace std;voidfight(charplayerA,charplayerB);intidexMax(intWinA[3]);intplayResult[3]={0,0,0},winA[3]={0,0,0},winB[3]={0,0,0};intmain(){intN;charplayerA,playerB;charindex[3]={'C','J','B'};cin>>N;while(N--){cin>>playerA>>playerB;fight(playerA,playerB);}cout<<playResult[0]<<" "<<playResult[1]<<" "<<playResult[2]<<endl;cout<<playResult[2]<<" "<<playResult[1]<<" "<<playResult[0]<<endl;cout<<index[idexMax(winA)]<<" "<<index[idexMax(winB)]<<endl;return0;}//save the player fight result.voidfight(charplayerA,charplayerB){if(playerA==playerB)playResult[1]++;else{switch(playerA){case'C':if(playerB=='B'){//B uses the 'B' win the playerplayResult[2]++;winB[2]++;}else{playResult[0]++;//A uses the 'C' win the playerwinA[0]++;}break;case'J':if(playerB=='C'){//B uses the 'C' win the playerplayResult[2]++;winB[0]++;}else{playResult[0]++;//A uses the 'J' win the playerwinA[1]++;}break;case'B':if(playerB=='J'){//B uses the 'J' win the playerplayResult[2]++;winB[1]++;}else{playResult[0]++;//A uses the 'C' win the playerwinA[2]++;}break;}}}intidexMax(intwin[3]){inttmp=2;if((win[2]>=win[0])&&(win[2]>=win[1])){tmp = 2;//output 'B' by priorityreturn2;}elseif((win[0]>=win[1])&&(win[0]>=win[2])){tmp = 0;//output 'C'return0;}elseif((win[1]>=win[0])&&(win[1]>=win[2])){tmp = 1;//output 'J'return1;}returntmp;}
#include<stdio.h> int main() { char a,b,Most[3]={'B','C','J'}; int N,i,compare; int RA[3]={0},A[3]={0},B[3]={0}; scanf("%d\n",&N); for(i=0;i<N;i++){ scanf("%c %c",&a,&b); getchar(); compare=(int)(a-b); if(compare==0) RA[1]++; if(compare==-7){ RA[0]++; A[1]++; } if(compare==7){ RA[2]++; B[1]++; } if(compare==1){ RA[2]++; B[0]++; } if(compare==-1){ RA[0]++; A[0]++; } if(compare==8){ RA[0]++; A[2]++; } if(compare==-8){ RA[2]++; B[2]++; } } printf("%d %d %d\n",RA[0],RA[1],RA[2]); printf("%d %d %d\n",RA[2],RA[1],RA[0]); N=0; compare=0; for(i=1;i<3;i++){ if(A[i]>A[N]) N=i; if(B[i]>B[compare]) compare=i; } printf("%c ",Most[N]); printf("%c",Most[compare]); return 0; }
#include<iostream> #include<cstdio> //C代表“锤子”、J代表“剪刀”、B代表“布” class solution{ public: int w[3]; int p; int l; public: void com(char a,char b) { if(a==b) { p+=1; } else if((a=='C'&&b=='J')||(a=='J'&&b=='B')||(a=='B'&&b=='C')) { if(a=='B') w[0]+=1; else if(a=='C') w[1]+=1; else { w[2]+=1; } } else l+=1; } void INI() { w[1]=w[2]=w[0]=p=l=0; } }; using namespace std; int main() { solution M,N; M.INI(); N.INI(); int n; cin>>n; char a,b; while(n--) { cin>>a>>b; M.com(a,b); N.com(b,a); } cout<<M.w[0]+M.w[1]+M.w[2]<<" "<<M.p<<" "<<M.l<<endl; cout<<N.w[0]+N.w[1]+N.w[2]<<" "<<N.p<<" "<<N.l<<endl; if(M.w[0]>=M.w[1]&&M.w[0]>=M.w[2]) cout<<"B"<<" "; else if(M.w[1]>M.w[0]&&M.w[1]>=M.w[2]) cout<<"C"<<" "; else cout<<"J"<<" "; if(N.w[0]>=N.w[1]&&N.w[0]>=N.w[2]) cout<<"B"; else if(N.w[1]>N.w[0]&&N.w[1]>=N.w[2]) cout<<"C"; else cout<<"J"; return 0; }