题解 | #扑克牌大小#
扑克牌大小
https://www.nowcoder.com/practice/d290db02bacc4c40965ac31d16b1c3eb
对不同的牌组打分就行,zorn引理偏序关系下必有链,对于合法,识别牌组分数够不够炸弹最低分
#include <stdio.h>
#define max(a,b) a>b?a:b
int trans(char c)
{
if(c=='J')return 11;
else if(c=='Q')return 12;
else if(c=='K')return 13;
else if(c=='A')return 14;
else if(c=='2')return 15;
else if(c=='1')return 10;//10-J-Q-K-A-2
else return c-'0';
}
int count(char *str,int n)
{
int len=strlen(str);
int num=trans(str[0]);
if(n==1)
{
if(str[1]=='o')return 16;
else if(str[1]=='O')return 17;
else return num;
}
else if(n==2)
{
if((str[0]=='j'&&str[6]=='J')||(str[0]=='J'&&str[6]=='j'))
return 884866;
else return num*11;
}
else if(n==3)
{
return num*111;
}
else if(n==4)
{
return num*1111;
}
else if(n==5)
{
return num*111;
}
return 0;
}
int number(char *str)
{
int counting=1;
for(int i=0;i<strlen(str);i++)
{
if(str[i]==' ')
counting+=1;
}
return counting;
}
int main() {
char str[400],str1[110],str2[110];
int lable=0;
gets(str);
for(int i=0;i<strlen(str);i++)
{
if(str[i]=='-')
{
lable=i;
continue;
}
if(lable == 0)
str1[i]=str[i];
else str2[i-lable-1]=str[i];
}
int n1=number(str1);
int n2=number(str2);
int count1=count(str1,n1);
int count2=count(str2,n2);
if(n1!=n2&&(count1<3333&&count2<3333))
printf("ERROR");
else{
if(count1>count2)
for(int i=0;i<strlen(str1);i++)
printf("%c",str1[i]);
else
for(int i=0;i<strlen(str2);i++)
printf("%c",str2[i]);
}
return 0;
}

