PAT (Basic Level) Practice (中文) 1018 锤子剪刀布

 

题目链接

 

#include 
int qw(int c,int b) {
  if (c == 0)
    printf("B");
  else if (c == 1)
    printf("C");
  else
    printf("J");
    
    
  if(b==1)
    printf(" ");
  return 0;
}
            
          
int main(){
  int a, b, c, d, g[3] = {0, 0, 0}, m[3] = {0, 0, 0}, n;
  b = 0;
  c = 0;
  d = 0;
  
  char e, f;
  scanf("%d", &n);
  getchar();
  for(a=1;a<=n;a++){
    scanf("%c %c", &e, &f);
    if (e == f) {
      c = c + 1;
    }
    if(e=='C'){
      if (f == 'J') {
        b++;
        g[1]++;
      }
      if (f == 'B') {
        d++;
        m[0]++;
      }
    }
    if(e=='J'){
      if (f == 'C') {
        d++;
        m[1]++;
      }
      if (f == 'B') {
        b++;
        g[2]++;
      }
    }
    if(e=='B'){
      if (f == 'J') {
        d++;
        m[2]++;
      }
      if (f == 'C') {
        b++;
        g[0]++;
      }
    }
      getchar();
  }
  printf("%d %d %d\n", b, c, d);
  printf("%d %d %d\n", d, c, b);
  c = 0;
  for (a = 0, b = g[0]; a < 3; a++) {
    if (b < g[a]) {
      c = a;
      b=g[a];
    }
  }
  qw(c,1);
  c = 0;
  for (a = 0, b = m[0]; a < 3; a++) {
    if (b < m[a]) {
      c = a;
      b=m[a];
    }
  }
  qw(c,0);
	return 0;
}

 

你可能感兴趣的:(乙级题,乙级题)