int main() { std::string * answ = makeAnswer(10); for (int i = 0; i < pow(4,10); i++) { if (answ[i][0] == 'y') { //第二题 第5题的答案 A(C) B(D) C(A) D(B) if (!(answ[i][2] == 'a'&&answ[i][5]=='c' || answ[i][2] == 'b'&&answ[i][5]=='d' || answ[i][2] == 'c'&&answ[i][5]=='a' || answ[i][2] == 'd'&&answ[i][5]=='b')) { answ[i][0] = 'n'; continue; }
//第三题 哪一题的答案与其他三项不同 A(3) B(6) C(2) D(4) switch (answ[i][3]) { case 'a': if (answ[i][2] == answ[i][3] || answ[i][4] == answ[i][3] || answ[i][6] == answ[i][3]) answ[i][0] = 'n'; break; case 'b': if (answ[i][2] == answ[i][6] || answ[i][4] == answ[i][6] || answ[i][3] == answ[i][6]) answ[i][0] = 'n'; break; case 'c': if (answ[i][6] == answ[i][2] || answ[i][4] == answ[i][2] || answ[i][3] == answ[i][2]) answ[i][0] = 'n'; break; case 'd': if (answ[i][2] == answ[i][4] || answ[i][6] == answ[i][4] || answ[i][3] == answ[i][4]) answ[i][0] = 'n'; break; } if (answ[i][0] == 'n') continue; //第四题 哪两道题答案相同 A(1、5) B(2、7) C(1、9) D(6、10) switch (answ[i][4]) { case 'a': if (answ[i][1] != answ[i][5]) answ[i][0] = 'n'; break; case 'b': if (answ[i][2] != answ[i][7]) answ[i][0] = 'n'; break; case 'c': if (answ[i][1] != answ[i][9]) answ[i][0] = 'n'; break; case 'd': if (answ[i][6] != answ[i][10]) answ[i][0] = 'n'; break; } if (answ[i][0] == 'n') continue;
//第五题 哪道题答案与本题相同 A(8) B(4) C(9) D(7) switch (answ[i][5]) { case 'a': if (answ[i][8] != answ[i][5]) answ[i][0] = 'n'; break; case 'b': if (answ[i][4] != answ[i][5]) answ[i][0] = 'n'; break; case 'c': if (answ[i][9] != answ[i][5]) answ[i][0] = 'n'; break; case 'd': if (answ[i][7] != answ[i][5]) answ[i][0] = 'n'; break; } if (answ[i][0] == 'n') continue;
//第六题 哪两题答案与第8题相同 A(2、4) B(1、6) C(3、10) D(5、9) switch (answ[i][6]) { case 'a': if (answ[i][8] != answ[i][2] || answ[i][8] != answ[i][4]) answ[i][0] = 'n'; break; case 'b': if (answ[i][8] != answ[i][1] || answ[i][8] != answ[i][6]) answ[i][0] = 'n'; break; case 'c': if (answ[i][8] != answ[i][3] || answ[i][8] != answ[i][10]) answ[i][0] = 'n'; break; case 'd': if (answ[i][8] != answ[i][5] || answ[i][8] != answ[i][9]) answ[i][0] = 'n'; break; } if (answ[i][0] == 'n') continue;
//第七题 被选中最少的选项字母 A\B\C\D int answer_num[4]{0}; enum abcd {a,b,c,d}; for (int j = 1; j <= 10; j++) { switch (answ[i][j]) { case 'a': answer_num[0]++; break; case 'b': answer_num[1]++; break; case 'c': answer_num[2]++; break; case 'd': answer_num[3]++; break; } } int min = answer_num[0],max = answer_num[0]; abcd minC = a,maxC = a; for (int n = 1; n < 4; n++) { if(min > answer_num[n]) { min = answer_num[n]; minC = abcd(n); } if (max < answer_num[n]) { max = answer_num[n]; maxC = abcd(n); } }
switch (answ[i][7]) { case 'a': if (minC != c) answ[i][0] = 'n'; break; case 'b': if (minC != b) answ[i][0] = 'n'; break; case 'c': if (minC != a) answ[i][0] = 'n'; break; case 'd': if (minC != d) answ[i][0] = 'n'; break; } if (answ[i][0] == 'n') continue;
//第八题 下面哪题答案与第1题答案不相邻 A(7) B(5) C(2) D(10) switch (answ[i][8]) { case 'a': if (int(answ[i][7]) - int(answ[i][1]) <= 1 && int(answ[i][7]) - int(answ[i][1]) >= -1) answ[i][0] = 'n'; break; case 'b': if (int(answ[i][5]) - int(answ[i][1]) <= 1 && int(answ[i][5]) - int(answ[i][1]) >= -1) answ[i][0] = 'n'; break; case 'c': if (int(answ[i][2]) - int(answ[i][1]) <= 1 && int(answ[i][2]) - int(answ[i][1]) >= -1) answ[i][0] = 'n'; break; case 'd': if (int(answ[i][10]) - int(answ[i][1]) <= 1 && int(answ[i][10]) - int(answ[i][1]) >= -1) answ[i][0] = 'n'; break; } if (answ[i][0] == 'n') continue;