Poker is one of the most widely played card games, and King's Poker is one of its variations. The game is played with a normal deck of 52 cards. Each card has one of 4 suits and one of 13 ranks. However, in King's Poker card suits are not relevant, while ranks are Ace (rank 1), 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack (rank 11), Queen (rank 12) and King (rank 13). The name of the game comes from the fact that in King's Poker, the King is the highest ranked card. But this is not the only difference between regular Poker and King's Poker. Players of King's Poker are dealt a hand of just three cards. There are three types of hands:
Hands are ranked using the following rules:
A new software house wants to offer King's Poker games in its on-line playing site, and needs a piece of software that, given a hand of King's Poker, determines the set or pair with the lowest rank that beats the given hand. Can you code it?
Each test case is described using a single line. The line contains three integers A, B, and C representing the ranks of the cards dealt in a hand (1A, B, C13).
The last test case is followed by a line containing three zeros.
For each test case output a single line. If there exists a set or a pair that beats the given hand, write the lowest ranked such a hand. The beating hand must be written by specifying the ranks of their cards, in non-decreasing order. If no set or pair beats the given hand, write the character `*' (asterisk).
1 1 1 1 1 12 1 1 13 1 13 1 10 13 10 1 2 2 13 13 13 13 12 13 12 12 12 3 1 4 1 5 9 0 0 0
2 2 2 1 1 13 1 2 2 1 2 2 1 11 11 2 2 3 * 1 1 1 13 13 13 1 1 2 1 1 2
清楚地判断好分类情况,然后一点点 if else 就行了~~
不知道有没有更好的方法,没思路~
代码:
#include <iostream> using namespace std; int main() { int a,b,c; while(cin>>a>>b>>c&&(a+b+c!=0)) { if(a==13&&b==13&&c==13) cout<<'*'<<endl; else if(a==b&&b==c) cout<<a+1<<" "<<b+1<<" "<<c+1<<endl; else if(a==b) { if(c==13) cout<<1<<" "<<a+1<<" "<<b+1<<endl; else if(c>a-1) cout<<a<<" "<<b<<" "<<c+1<<endl; else if(c<a-1) cout<<c+1<<" "<<a<<" "<<b<<endl; else if(a==13&&c==12) cout<<1<<" "<<1<<" "<<1<<endl; else cout<<a<<" "<<b<<" "<<c+2<<endl; } else if(c==b) { if(a==13) cout<<1<<" "<<c+1<<" "<<b+1<<endl; else if(a>b-1) cout<<c<<" "<<b<<" "<<a+1<<endl; else if(a<b-1) cout<<a+1<<" "<<b<<" "<<c<<endl; else if(c==13&&a==12) cout<<1<<" "<<1<<" "<<1<<endl; else cout<<c<<" "<<b<<" "<<a+2<<endl; } else if(a==c) { if(b==13) cout<<1<<" "<<a+1<<" "<<c+1<<endl; else if(b>a-1) cout<<a<<" "<<c<<" "<<b+1<<endl; else if(b<a-1) cout<<b+1<<" "<<c<<" "<<a<<endl; else if(c==13&&b==12) cout<<1<<" "<<1<<" "<<1<<endl; else cout<<a<<" "<<c<<" "<<b+2<<endl; } else if(a!=b&&b!=c&&c!=a) cout<<1<<" "<<1<<" "<<2<<endl; } return 0; }