解题思路:
因为题目的编辑中已经是知道了最终结果的,所以,可以倒过来思考,通过知晓的结果来判断相对应的过程是否符合对应的猜想,简单来说就是,自己称重硬币的过程,是不是就是出题者的意图,所以,需要建立三个数组来存放相对应的称重数据,最后用枚举的办法,依次比对结果是不是符合,最终得出硬币的真假。
代码如下:
#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;