codeup问题I:剪刀锤子布
#include <stdio.h>int main(){
int N;
char man1,man2;
int win1 = 0,win2 = 0,draw = 0,lose1 = 0,lose2 = 0;
int C1 = 0,C2 = 0,J1 = 0,J2 = 0,B1 = 0,B2 = 0;
char max1,max2;
scanf("%d",&N);
getchar();
while(N--){
scanf("%c %c",&man1,&man2);
getchar();
if(man1 == 'C'){
if(man2 == 'C'){
draw++;
}
if(man2 == 'J'){
win1++;
lose2++;
C1++;
}
if(man2 == 'B'){
win2++;
lose1++;
B2++;
}
}
if(man1 == 'J'){
if(man2 == 'C'){
win2++;
lose1++;
C2++;
}
if(man2 == 'J'){
draw++;
}
if(man2 == 'B'){
win1++;
lose2++;
J1++;
}
}
if(man1 == 'B'){
if(man2 == 'C'){
win1++;
lose2++;
B1++;
}
if(man2 == 'J'){
win2++;
lose1++;
J2++;
}
if(man2 == 'B'){
draw++;
}
}
}
printf("%d %d %d\n",win1,draw,lose1);
printf("%d %d %d\n",win2,draw,lose2);
max1 = C1;
max2 = C2;
if(max1 < B1)
max1 = B1;
if(max1 < J1)
max1 = J1;
if(max2 < B2)
max2 = B2;
if(max2 < J2)
max2 = J2;
//max1 = C1 > J1 ? (C1 > B1 ? C1 : B1) : (J1 > B1 ? J1 : B1);
//max2 = C2 > J2 ? (C2 > B2 ? C2 : B2) : (J2 > B2 ? J2 : B2);
if(B1 == max1){
printf("B ");
}else if(C1 == max1){
printf("C ");
}else{
printf("J ");
}
if(B2 == max2){
printf("B");
}else if(C2 == max2){
printf("C");
}else{
printf("J");
}
return 0;
}
通过测试点86%,不知道哪里还有错误,求助。 原题地址:http://codeup.cn/problem.php?cid=100000575&pid=8
页:
[1]