#include<iostream>
#include<cstring>
using namespace std;
char Left[3][7];
char Right[3][7];
char result[3][7];
bool IsFake(char c, bool light);
int main()
{
int t;
cin >> t;
while (t--) {
for (int i = 0; i < 3; ++i) {
cin >> Left[i] >> Right[i] >> result[i];
}
for (char c = 'A'; c <= 'L'; c++) {
if (IsFake(c, true)) {
cout << c << "is the counterfeit coin and it is light.\n";
break;
}
else if (IsFake(c, false)) {
cout << c << "is the counterfeit coin and it is heavy.\n";
break;
}
}
}
return 0;
}
bool IsFake(char c, bool light)
{
for (int i = 0; i < 3; ++i) {
char* pLeft, * pRight;//指向天平两边的字符串
if (light) {
pLeft = Left[i];
pRight = Right[i];
}
else {//如果假设假币是重的,则把称量结果左右对换
pLeft = Right[i];
pRight = Left[i];
}
switch (result[i][0])
{//天平右边的情况
case 'u':
if (strchr(pRight, c) == NULL)
return false;
break;
case 'e':
if (strchr(pLeft, c) || strchr(pRight, c))
return false;
break;
case 'd':
if (strchr(pLeft, c) == NULL)
return false;
break;
}
}
return true;
}
称硬币
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...