Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:做得跟SAMPLE一样,但是不应该会WA啊In Reply To:做得跟SAMPLE一样,但是不应该会WA啊 Posted by:mark_still at 2005-08-11 18:57:34 > #include <iostream> > #include <string> > using namespace std; > > struct card > { > int face; > int suit; > }cd[4]; > > bool smaller(card a,card b) > { > if(a.suit<b.suit) return true; > else if(a.suit==b.suit&&a.face<b.face) return true; > else return false; > } > > card guess() > { > card c; > c.suit=cd[0].suit; > if(smaller(cd[1],cd[2])) > { > if(smaller(cd[1],cd[3])) > { > if(smaller(cd[2],cd[3])) c.face=cd[0].face+1; > else c.face=cd[0].face+2; > } > else c.face=cd[0].face+4; > } > else if(smaller(cd[1],cd[3])) c.face=cd[0].face+3; > else if(smaller(cd[2],cd[3])) c.face=cd[0].face+5; > else c.face=cd[0].face+6; > return c; > } > > int main() > { > string s; > int n; > cin>>n; > for(int j=0;j<n;j++) > { > for(int i=0;i<4;i++) > { > cin>>s; > if(s[0]<='9') cd[i].face=s[0]-'0'; > else if(s[0]=='T') cd[i].face=10; > else if(s[0]=='J') cd[i].face=11; > else if(s[0]=='Q') cd[i].face=12; > else cd[0].face=13; > if(s[1]=='H') cd[i].suit=1; > else if(s[1]=='C') cd[i].suit=2; > else if(s[1]=='D') cd[i].suit=3; > else cd[i].suit=4; > } > card c=guess(); > if(c.face>13) c.face=c.face-13; > if(c.face<=9) cout<<c.face; > else if(c.face==10) cout<<'T'; > else if(c.face==11) cout<<'J'; > else if(c.face==12) cout<<'Q'; > else cout<<'K'; > > if(c.suit==1) cout<<'H'; > else if(c.suit==2) cout<<'C'; > else if(c.suit==3) cout<<'D'; > else cout<<'S'; > cout<<endl; > } > return 0; > } > > 判断牌没有问题啊,难道输入输出有问题~~~ Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator