某学校进行了一次英语考试,共有10道是非题,每题为10分,解答用1表示“是”,用0表示“非”的方式。但老师批完卷后,发现漏批了一张试卷,而且标准答案也丢失了,手头只剩下了3张标有分数的试卷。
试卷一:① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
0 0 1 0 1 0 0 1 0 0 得分:70
试卷二:① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
0 1 1 1 0 1 0 1 1 1 得分:50
试郑三:① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
0 1 1 1 0 0 0 1 0 1 得分:30
待批试卷:① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩
0 0 1 1 1 0 0 1 1 1 得分:?
问题求解:
请编一程序依据这三张试卷,算出漏批的那张试卷的分数。
可以打表
//题目在100004545454459870234876903456 #include<bits/stdc++.h> using namespace std; int score[5]; int a[5][11]={ {0,0,0,0,0,0,0,0,0,0,0 }, {0,0,0,1,0,1,0,0,1,0,0 }, {0,0,1,1,1,0,1,0,1,1,1 }, {0,0,1,1,1,0,0,0,1,0,1 }, {0,0,0,1,1,1,0,0,1,1,1 } }; void tryy(int dep) { for(int ans=0;ans<=1;ans++) { for(int i=1;i<=4;i++)//试卷 if(a[i][dep]==ans) score[i]+=10; if(dep==10) { if(score[1]==70 && score[2]==50 && score[3]==30)//判断 { cout<<score[4]<<endl; return ; } } else tryy(dep+1); for(int i=1;i<=4;i++) if(a[i][dep]==ans) score[i]-=10; } } int main() { tryy(1) ; }
-