{"id":5300,"date":"2024-09-20T23:01:01","date_gmt":"2024-09-20T15:01:01","guid":{"rendered":""},"modified":"2024-09-20T23:01:01","modified_gmt":"2024-09-20T15:01:01","slug":"\u534e\u4e3a\uff1a\u5e72\u77aa\u773c_\u5e72\u77aa\u773c\u6e38\u620f\u5927\u5385","status":"publish","type":"post","link":"https:\/\/mushiming.com\/5300.html","title":{"rendered":"\u534e\u4e3a\uff1a\u5e72\u77aa\u773c_\u5e72\u77aa\u773c\u6e38\u620f\u5927\u5385"},"content":{"rendered":"
\/* \u5e72\u77aa\u773c \u95ee\u9898\u63cf\u8ff0\uff1a \u5728\u6210\u90fd\uff0c\u6d41\u884c\u4e00\u79cd\u6251\u514b\u6e38\u620f\u53eb\u201c\u5e72\u77aa\u773c\u201d\u3002\u4f7f\u7528\u6251\u514b\u724c\uff0c\u5305\u62ec\uff1aA(1),2,3,4,5,6,7,8,9,T(10),J(11),Q(12),K(13)\u3002 \u6ce8\u610f\uff1a10\u7528T\u66ff\u6362\uff0c\u8fd9\u91cc\u6682\u65f6\u4e0d\u8003\u8651\u5927\u9b3c\u548c\u5c0f\u9b3c\u3002 \u4e24\u624b\u724c\u7684\u5927\u5c0f\u89c4\u5219\u5982\u4e0b\uff1a a) \u5355\u724c\uff1a4\u6bd43\u5927\uff0c5\u6bd44\u5927\uff0c\u53ea\u6709\u4e24\u5f20\u724c\u521a\u597d\u5927\u4e00\u70b9\u65f6\u624d\u80fd\u8fdb\u884c\u6bd4\u8f83\uff0c\u6bd4\u8f83\u987a\u5e8f\u4e3a\uff1aA>K>Q>J>T>9>8>7>6>5>4>3\u3002 \u6bd4\u5982\uff1a6\u5927\u4e8e5\uff0c\u4f46\u662f\u4e0d\u80fd\u6bd44\u5927\uff0c6\u548c4\u4e0d\u80fd\u6bd4\u8f83\u3002\u5355\u724c2\u5c5e\u4e8e\u7279\u6b8a\u724c\uff0c\u4ed6\u53ef\u4ee5\u548c\u5176\u4ed6\u6240\u6709\u666e\u901a\u5355\u724c\u6bd4\u8f83\uff0c \u5e76\u4e14\u662f\u6700\u5927\u7684\u3002 \u8bf7\u6ce8\u610f3\uff0c\u4ed6\u4e0d\u80fd\u5927\u4e8e\u4efb\u4f55\u724c\u3002 b) \u5bf9\u5b50\uff1a\u5373\u4e24\u5f20\u724c\u7684\u70b9\u6570\u76f8\u540c\uff0c\u89c4\u5219\u548c\u5355\u724c\u76f8\u4f3c\uff0c\u4e5f\u9700\u8981\u8fdb\u884c\u7c7b\u4f3c\u5904\u7406\u3002\u4e24\u4e2a2\u662f\u7279\u6b8a\u5bf9\u5b50\uff0c \u53ef\u4ee5\u5927\u4e8e\u6240\u6709\u7684\u5176\u4ed6\u5bf9\u5b50\u3002 \u6ce8\u610f\uff1a\u5bf9\u5b50\u548c\u5355\u724c\u662f\u4e0d\u80fd\u8fdb\u884c\u6bd4\u8f83\u7684\u3002 c) \u70b8\u5f39\uff1a3\u4e2a\u70b9\u6570\u76f8\u540c\u7684\u724c\u3002\u70b8\u5f39\u53ef\u4ee5\u5927\u4e8e\u4efb\u4f55\u5355\u5f20\u548c\u5bf9\u5b50\uff0c\u70b8\u5f39\u4e4b\u95f4\u7684\u6bd4\u8f83\u4e0d\u7528\u50cf\u5355\u724c\u548c\u5bf9\u5b50\u90a3\u6837\uff0c \u53ea\u80fd\u5927\u4e00\u70b9\u624d\u80fd\u6bd4\u8f83\u3002 \u53ea\u8981\u6ee1\u8db3\uff1a222>AAA>KKK>Q>JJJ>TTT>\u2026>333\u7684\u89c4\u5219\u7684\u5373\u53ef\u3002\u5373222\u662f\u6700\u5927\u7684\uff0cAAA\u53ef\u4ee5\u5927\u4e8eKKK\uff0c\u4e5f\u53ef\u4ee5\u5927\u4e8e333\u3002 d) \u5176\u4ed6\u89c4\u5219\u6682\u4e0d\u8003\u8651\u5b9e\u73b0 \u73b0\u5728\u8bf7\u4f60\u5b9e\u73b0\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u81ea\u52a8\u5224\u65ad\u4e24\u624b\u724c\u7684\u5927\u5c0f\uff0c\u6ce8\u610f\uff1a\u8f93\u5165\u7684\u724c\u53ea\u4f1a\u51fa\u73b03\u79cd\u7c7b\u578b\uff1a\u5355\u5f20\uff0c\u5bf9\u5b50\uff0c\u70b8\u5f39\u3002 \u5f20\u6570\u6700\u591a3\u5f20\u3002 \u4e0d\u4f1a\u51fa\u73b02\u4e2a\u5355\u724c\u3002\u6bd4\u5982\u201d25\u201d\uff0c\u4e5f\u4e0d\u4f1a\u51fa\u73b0\u4e00\u4e2a\u5bf9\u5b50\u52a0\u5355\u724c\uff0c\u6bd4\u5982\u201d334\u201d\u7b49\uff0c\u7c7b\u4f3c\u8f93\u5165\u5f02\u5e38\u4f60\u53ef\u4ee5\u4e0d\u7528\u8003\u8651\u3002 \u4f46\u662fpFirstCards\u4e3a\u5355\u724c\uff0cpSecondCards\u4e3a\u5bf9\u5b50\uff0c\u7c7b\u4f3c\u7684\u7ec4\u5408\u8f93\u5165\u662f\u5408\u6cd5\u7684\u3002 \u8981\u6c42\u5b9e\u73b0\u51fd\u6570\uff1a int CompareCards(char *pFirstCards, char *pSecondCards) \u3010\u8f93\u5165\u3011 char *pFirstCards\uff1a\u9700\u8981\u6bd4\u8f83\u7684\u7b2c\u4e00\u624b\u724c char *pSecondCards\uff1a\u9700\u8981\u6bd4\u8f83\u7684\u7b2c\u4e8c\u624b\u724c \u3010\u8fd4\u56de\u3011 int \u7c7b\u578b\uff0c\u8fd4\u56de\u503c\u8bf4\u660e\uff1a \u5982\u679cpFirstCards\u548c pSecondCards\u65e0\u6cd5\u6bd4\u8f83\uff0c\u6bd4\u5982\u201d3\u201d\u548c\u201d6\u201d\uff1b\u201d55\u201d\u548c\u201d6\u201d\u7b49\uff0c\u8fd4\u56de0\u3002 \u5982\u679cpFirstCards\u5927\u4e8epSecondCards\uff0c\u8fd4\u56de1\u3002 \u5982\u679cpFirstCards\u7b49\u4e8e pSecondCards\uff0c\u8fd4\u56de2\u3002 \u5982\u679cpFirstCards\u5c0f\u4e8e pSecondCards\uff0c\u8fd4\u56de3\u3002 \u6ce8\u610f\uff1a\u4e0d\u7528\u8003\u8651\u8f93\u5165\u7684\u5408\u6cd5\u6027\uff0c\u8fd9\u4e2a\u7531\u51fd\u6570\u7684\u4f7f\u7528\u8005\u4fdd\u8bc1\u3002\u8f93\u5165\u7684\u724c\u5747\u4e3a\u5b57\u7b26\u20191\u2019,\u20192\u2019..\u20199\u2019,\u5927\u5199\u7684\u2019A\u2019\uff0c\u2019T\u2019\uff0c\u2019J\u2019\uff0c\u2019Q\u2019\uff0c\u2019K\u2019\u3002 \u793a\u4f8b \u8f93\u5165\uff1a \u201c77\u201d\u3001 \u201c33\u201d\uff0c\u8fd4\u56de\uff1a0 \u8f93\u5165\uff1a \u201c77\u201d\u3001 \u201c77\u201d\uff0c\u8fd4\u56de\uff1a2 *\/ #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int MAX=256; int CompareCards(char *pFirstCards, char *pSecondCards) { char hash[MAX]={0}; char table[]=\"2AKQJT\"; for(int i=0;i<15;i++) { hash[table[i]]=i; } int len1=strlen(pFirstCards),len2=strlen(pSecondCards); \/\/\u5148\u8003\u8651\u6709\u70b8\u5f39\u7684\u60c5\u51b5 if(len1==3&&len2<3)return 1; if(len2==3&&len1<3)return 3; if(len1==3&&len2==3) { if(hash[*pFirstCards]>hash[*pSecondCards])return 3; if(hash[*pFirstCards]<hash[*pSecondCards])return 1; if(hash[*pFirstCards]==hash[*pSecondCards])return 2; } \/\/\u8003\u8651\u6ca1\u6709\u70b8\u5f39\u7684\u60c5\u51b5\uff0c\u8003\u8651\u5bf9\u5b50\u7684\u60c5\u51b5 if(len1==2&&len2==2) { if((hash[*pFirstCards]-hash[*pSecondCards])==0)return 2; if(hash[*pFirstCards]==0)return 1; if(hash[*pSecondCards]==0)return 3; if((hash[*pFirstCards]-hash[*pSecondCards])==1)return 3; if((hash[*pFirstCards]-hash[*pSecondCards])==-1)return 1; } \/\/\u8003\u8651\u5355\u5b50\u7684\u60c5\u51b5 if(len1==1&&len2==1) { if((hash[*pFirstCards]-hash[*pSecondCards])==0) return 2; if(hash[*pFirstCards]==0)return 1; if(hash[*pSecondCards]==0)return 3; if((hash[*pFirstCards]-hash[*pSecondCards])==1)return 3; if((hash[*pFirstCards]-hash[*pSecondCards])==-1)return 1; } return 0; } int main() { char *p1=\"777\",*p2=\"777\"; cout<<\"CompareCards \"<<CompareCards(p1,p2)<<endl; } <\/code><\/pre>\n

<\/p>\n","protected":false},"excerpt":{"rendered":"\u534e\u4e3a\uff1a\u5e72\u77aa\u773c_\u5e72\u77aa\u773c\u6e38\u620f\u5927\u5385\/*\u5e72\u77aa\u773c\u95ee\u9898\u63cf\u8ff0\uff1a\u5728\u6210\u90fd\uff0c\u6d41\u884c\u4e00\u79cd\u6251\u514b\u6e38\u620f\u53eb\u201c\u5e72\u77aa\u773c\u201d","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/5300"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=5300"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/5300\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=5300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=5300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=5300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}