12枚硬币分组称重,判断哪一枚硬币自己假币,重了还是轻了.

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 light.\n";
break;

        }
        else if (IsFake(c, false)) {
            cout << c << "is heavy.\n";
            break;
        }

    }

}

}
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;
}

为什么return false就是硬币重了呢,硬币重了变量c也包含在字符串里面的呀.

枚举,三分都可以

二分?