{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

1111 -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<algorithm> #include<vector> using namespace std; enum { SIZ = 5, }; const char cStr[] = "JQKA"; int getVal(char c){ int i; if (isdigit(c)){ return c-'0'; } for (i=0; cStr[i] && cStr[i]!=c; ++i) ; if (cStr[i]) return 11 + i; } char buf[10]; struct Card { int val; char type; bool read(){ if (scanf("%s", buf) <= 0) return false; type = buf[1]; val = getVal(buf[0]); return true; } bool operator <(const Card&o)const{ return val < o.val; } }; struct Node { Card car[5]; vector<int> vec; bool read(){ for (int i=0; i<5; ++i){ if(!car[i].read()) return false; } sort(car, car+5); vec.clear(); return true; } int cmp(const Node&o){ int i; for (int i=0; i<vec.size()&&i<o.vec.size(); ++i){ if (vec[i] != o.vec[i]) return vec[i] - o.vec[i]; } return 0; } int calcMost(){ int m = 0, v=1; for(int i=0; i<4; ++i){ if (car[i].val == car[i+1].val){ ++v; }else { v = 1; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
if (m < v) m = v; } return m; } bool StraightFlush(){ for(int i=0; i<4; ++i){ if(car[i].type!=car[i+1].type || car[i].val+1 != car[i+1].val) return false; } vec.push_back(10); vec.push_back(car[4].val); return true; } bool FourKind(){ int v = calcMost(); if (v < 4) return false; vec.push_back(9); if (car[0].val != car[1].val) vec.push_back(car[1].val); else if(car[3].val != car[4].val)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}