Logo Joker的博客

博客

#12958桥牌真是一道“模拟”

2023-11-20 21:49:09 By Joker
#include<bits/stdc++.h>
using namespace std;
int N,E,S,W;
void check(char ch,char x){
  if(ch=='N'){
      if(x=='A')
        N+=4;
      else if(x=='K')
        N+=3;
      else if(x=='Q')
        N+=2;
      else if(x=='J')
        N+=1;
  }
  if(ch=='S'){
      if(x=='A')
        S+=4;
      else if(x=='K')
        S+=3;
      else if(x=='Q')
        S+=2;
      else if(x=='J')
        S+=1;
  }
  if(ch=='E'){
      if(x=='A')
        E+=4;
      else if(x=='K')
        E+=3;
      else if(x=='Q')
        E+=2;
      else if(x=='J')
        E+=1;
  }
  if(ch=='W'){
      if(x=='A')
        W+=4;
      else if(x=='K')
        W+=3;
      else if(x=='Q')
        W+=2;
      else if(x=='J')
        W+=1;
  }
}
int main(){
  char ch;
  cin>>ch;
  string s;
  cin>>s;
  char s1[14],s2[14],s3[14],s4[14];
  for(int i=0;i<s.size();i++){
      if(i%4==0)
        s1[i/4]=s[i];
      if(i%4==1)
        s2[i/4]=s[i];
      if(i%4==2)
        s3[i/4]=s[i];
      if(i%4==3)
        s4[i/4]=s[i];
  }
  N=E=S=W=0;
  if(ch=='N'){
      for(int i=0;i<14;i++){
        check('E',s1[i]);
        check('S',s2[i]);
        check('W',s3[i]);
        check('N',s4[i]);
    }
    printf("N %d E %d S %d W %d",N,E,S,W);
  }
  if(ch=='S'){
      for(int i=0;i<14;i++){
        check('W',s1[i]);
        check('N',s2[i]);
        check('E',s3[i]);
        check('S',s4[i]);
    }
    printf("S %d W %d N %d E %d",S,W,N,E);
  }
  if(ch=='W'){
      for(int i=0;i<14;i++){
        check('N',s1[i]);
        check('E',s2[i]);
        check('S',s3[i]);
        check('W',s4[i]);
    }
    printf("W %d N %d E %d S %d",W,N,E,S);
  }
  if(ch=='E'){
      for(int i=0;i<14;i++){
        check('S',s1[i]);
        check('W',s2[i]);
        check('N',s3[i]);
        check('E',s4[i]);
    }
    printf("E %d S %d W %d N %d",E,S,W,N);
  }
  return 0;
}

用了我1.7kb,真牛逼

评论

暂无评论

发表评论

可以用@mike来提到mike这个用户,mike会被高亮显示。如果你真的想打“@”这个字符,请用“@@”。