最佳外贸建站平台,西安市做网站,中卫平面设计师招聘,中国交通频道在线直播2022批改多选题是比较麻烦的事情#xff0c;本题就请你写个程序帮助老师批改多选题#xff0c;并且指出哪道题错的人最多。 输入格式#xff1a; 输入在第一行给出两个正整数 N#xff08;≤ 1000#xff09;和 M#xff08;≤ 100#xff09;#xff0c;分别是学生人数和多… 批改多选题是比较麻烦的事情本题就请你写个程序帮助老师批改多选题并且指出哪道题错的人最多。 输入格式 输入在第一行给出两个正整数 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无法完成匹配正确的结果
#includecstdio
#includecstring
#includeiostream
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;
} 转载于:https://www.cnblogs.com/wanghao-boke/p/10399507.html