B1061 判斷題 (15分)
阿新 • • 發佈:2019-01-20
cstring sin 簡單的 超過 return algorithm pro for ring
B1061 判斷題 (15分)
判斷題的評判很簡單,本題就要求你寫個簡單的程序幫助老師判題並統計學生們判斷題的得分。
輸入格式:
輸入在第一行給出兩個不超過 100 的正整數 N 和 M,分別是學生人數和判斷題數量。第二行給出 M 個不超過 5 的正整數,是每道題的滿分值。第三行給出每道題對應的正確答案,0 代表“非”,1 代表“是”。隨後 N 行,每行給出一個學生的解答。數字間均以空格分隔。
輸出格式:
按照輸入的順序輸出每個學生的得分,每個分數占一行。
輸入樣例:
3 6
2 1 3 3 4 5
0 0 1 0 1 1
0 1 1 0 0 1
1 0 1 0 1 0
1 1 0 0 1 1
輸出樣例:
13 11 12
思考
3 6 /*人數和題目數*/
2 1 3 3 4 5/*得分*/
0 0 1 0 1 1/*答案*/
0 1 1 0 0 1
1 0 1 0 1 0
1 1 0 0 1 1
AC代碼
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<cstdlib> using namespace std; int main(void){ int n,m,sum=0; scanf("%d %d", &n,&m); int *pro_ans; int *goal; int *ans; pro_ans = new int[m]; goal = new int[m]; ans = new int[m]; for(int i = 0;i<m;i++){ scanf("%d", &goal[i]); } for(int i = 0;i<m;i++){ scanf("%d", &pro_ans[i]); } for(int i=0;i<n;i++){ sum = 0; for(int j=0;j<m;j++){ scanf("%d", &ans[j]); if(ans[j]==pro_ans[j]){ sum+=goal[j]; } } printf("%d\n", sum); } delete [] pro_ans; delete [] goal; delete [] ans; return 0; }
B1061 判斷題 (15分)