判斷題的評判很簡單,本題就要求你寫個簡單的程序幫助老師判題并統計學生們判斷題的得分。
輸入格式:
輸入在第一行給出兩個不超過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
#include <iostream>using namespace std;int main(){ int N; int M; cin>>N>>M; int Student_Score[N] = {0}; int Score[M]; int Right_Answer[M]; int Student_Answer[N][M]; for ( int i = 0 ; i < M ; i++){ cin>>Score[i]; } for ( int i = 0 ; i < M ; i++){ cin>>Right_Answer[i]; } for ( int i = 0 ; i < N ; i++){ for ( int j = 0 ; j < M ; j++){ cin>>Student_Answer[i][j]; if (Student_Answer[i][j] == Right_Answer[j]){ Student_Score[i] += Score[j]; } } } cout<<Student_Score[0]; for ( int i = 1 ; i < N ; i++){ cout<<endl<<Student_Score[i]; } return 0; }新聞熱點
疑難解答