公司办网站大概多少钱软件定制开发
所谓“三带一”牌型,即四张手牌中,有三张牌一样,另外一张不与其他牌相同,换种说法,四张手牌经过重新排列后,可以组成 AAABAAAB 型。
输入格式
第一行输入一个整数 TT ,代表斗地主的轮数。
接下来 TT 行,每行输入一个长度为 44 的字符串,代表小蓝的手牌。
字符 { 'A','2','3','4','5','6','7','8','9','X','J','Q','K'
} 对应代表牌面 { A,2,3,4,5,6,7,8,9,10,J,Q,KA,2,3,4,5,6,7,8,9,10,J,Q,K } 。
牌面中不包含大小王。
输出格式
输出 TT 行,每行一个字符串,如果当前牌是“三带一”牌型,输出 Yes
,否则输出 No
。
#include <iostream>
#include <string>
using namespace std;int main() {int T;cin >> T;while (T--) {string s;cin >> s;int count[13] = {0};for (char c : s) {int index;if (c == 'A') {index = 0;} else if (c == 'X') {index = 9;} else if (c == 'J') {index = 10;} else if (c == 'Q') {index = 11;} else if (c == 'K') {index = 12;} else {index = c - '2' + 1; // 处理'2'到'9'}count[index]++;}int distinct = 0;int max_count = 0;for (int i = 0; i < 13; ++i) {if (count[i] > 0) {distinct++;if (count[i] > max_count) {max_count = count[i];}}}if (distinct == 2 && max_count == 3) {cout << "Yes" << endl;} else {cout << "No" << endl;}}return 0;
}