题解 | #扑克牌大小#
扑克牌大小
https://www.nowcoder.com/practice/0a92c75f5d6b4db28fcfa3e65e5c9b3f
#include <iostream> #include<string> #include<algorithm> using namespace std; string Res(const string& s) { if(s.find("joker JOKER")!=string::npos) return "joker JOKER"; int sub=s.find('-'); string s1=s.substr(0,sub); string s2=s.substr(sub+1); int len1=count(s1.begin(),s1.end(),' ')+1; int len2=count(s2.begin(),s2.end(),' ')+1; string f1=s1.substr(0,s1.find(' ')); string f2=s2.substr(0,s2.find(' ')); if(len1==len2) { string str="345678910JQKA2jokerJOKER"; if(str.find(f1)>str.find(f2)) { return s1; } return s2; } if(len1==4) { return s1; } else if(len2==4) return s2; else return "ERROR"; } int main(){ string s; getline(cin,s); cout<<Res(s)<<endl; } // 64 位输出请用 printf("%lld")