批改多選題是比較麻煩的事情,本題就請你寫個程序幫助老師批改多選題,并且指出哪道題錯的人最多。
輸入格式:
輸入在第一行給出兩個正整數 N(≤?1000)和 M(≤?100),分別是學生人數和多選題的個數。隨后 M 行,每行順次給出一道題的滿分值(不超過 5 的正整數)、選項個數(不少于 2 且不超過 5 的正整數)、正確選項個數(不超過選項個數的正整數)、所有正確選項。注意每題的選項從小寫英文字母 a 開始順次排列。各項間以 1 個空格分隔。最后 N 行,每行給出一個學生的答題情況,其每題答案格式為?(選中的選項個數 選項1 ……)
,按題目順序給出。注意:題目保證學生的答題情況是合法的,即不存在選中的選項數超過實際選項數的情況。
輸出格式:
按照輸入的順序給出每個學生的得分,每個分數占一行。注意判題時只有選擇全部正確才能得到該題的分數。最后一行輸出錯得最多的題目的錯誤次數和編號(題目按照輸入的順序從 1 開始編號)。如果有并列,則按編號遞增順序輸出。數字間用空格分隔,行首尾不得有多余空格。如果所有題目都沒有人錯,則在最后一行輸出?Too simple
。
輸入樣例:
3 4
3 4 2 a c
2 5 1 b
5 3 2 b c
1 5 4 a b d e
(2 a c) (2 b d) (2 a c) (3 a b e)
(2 a c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (2 b c) (4 a b c d)
輸出樣例:
3
6
5
2 2 3 4
//fgets(stu[i].option,10,stdin) //scanf("(%d%[^)]",&num_correct,str); //這兩個輸入的字符串在最后的結尾處\n不相等,會導致strcmp無法完成匹配正確的結果 #include<cstdio> #include<cstring> #include<iostream> using namespace std; const int maxn = 1010; struct Student{int grade;int num_option;int num_right;char option[60];int wrongTimes; }stu[maxn];int main(){int n,m;//the numbers of the student and the questionscanf("%d%d",&n,&m);for(int i = 1; i <= m; i++){scanf("%d%d%d",&stu[i].grade,&stu[i].num_option,&stu[i].num_right);//scanf("%s",stu[i].option);//store the string including the front space //fgets(stu[i].option,10,stdin);//gets(stu[i].option); cin.getline(stu[i].option,maxn);}int wrongMax = -1;//record the question that the highest time of errors people makebool isWrong = false;//if there is a mistake,isWrong will become truefor(int i = 1; i <= n; i++){char str[100]; //store the option that students selectint sum = 0,num_correct; //store the grades that students getfor(int j = 1; j <= 4; j++){scanf("(%d%[^)]",&num_correct,str);//the function of %[^)] is store all character except ')'scanf(")");getchar(); if(num_correct == stu[j].num_right){if(strcmp(str,stu[j].option) == 0){sum += stu[j].grade;}else{stu[j].wrongTimes++;if(stu[j].wrongTimes > wrongMax) wrongMax = stu[j].wrongTimes;isWrong = true;}}else{stu[j].wrongTimes++;if(stu[j].wrongTimes > wrongMax) wrongMax = stu[j].wrongTimes;isWrong = true;}}printf("%d\n",sum);}if(!isWrong) printf("Too Simple\n");else{printf("%d",wrongMax);for(int i = 1; i <= m; i++){if(stu[i].wrongTimes == wrongMax) printf(" %d",i);}}return 0; }
?