PAT乙级1073 多选题常见计分法 (20 分)

本文介绍了一个用于处理复杂选择题的评分系统,该系统不仅能够计算学生的得分,还能统计每个题目中被错误选择最多的选项,为教师提供详细的错误分析。系统使用C++编程语言实现,涉及字符串处理、数据结构和算法设计。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目链接

实现(做的比较繁琐,以后再想吧!)

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
struct node {
	int score;
	int chooseNum;
	int correctNum;
	int wrongNum;	//学生错误次数
	int options[5];	//记录各个选项的错误次数
	string answer;
};
int main()
{
	int N, M,i,j,score,choose;
	char ch;
	string str;
	cin >> N >> M;
	vector<node> ques(M);
	for (i = 0; i < M; i++)
	{
		cin >> ques[i].score >> ques[i].chooseNum >> ques[i].correctNum;
		ques[i].answer = "";
		ques[i].wrongNum = 0;
		for (j = 0; j < 5; j++) ques[i].options[j] = 0;
		for (j = 0; j < ques[i].correctNum; j++)
		{
			cin >> ch;
			ques[i].answer += ch;
		}
	}
	getchar();
	int wrongNum=0,count=0,m;
	double getScore = 0;
	string answer;
	bool wrong ;
	for (i = 0; i < N; i++)
	{
		getScore = 0; answer = "";
		getline(cin, str);
		str.erase(remove(str.begin(), str.end(),' '),str.end());
		str.erase(remove(str.begin(), str.end(), '('), str.end());
		str.erase(remove(str.begin(), str.end(), ')'), str.end());
		for (j = 0,count=0; j < str.size();)
		{
			wrong = false;
			answer = str.substr(j+1, str[j]-'0');
			if (answer == ques[count].answer)
				getScore += ques[count].score;
			else
			{
				ques[count].wrongNum++;
				for (m = 0; m < answer.size(); m++)
				{
					if (ques[count].answer.find(answer[m]) == string::npos)
					{
						wrong = true; 
						ques[count].options[answer[m] - 'a'] += 1;
					}
				}
				for (m = 0; m < ques[count].answer.size(); m++)
				{
					if (answer.find(ques[count].answer[m]) == string::npos)
						ques[count].options[ques[count].answer[m] - 'a'] += 1;
				}
				if (!wrong)
					getScore += (ques[count].score*1.0) / 2;
			}
			j += str[j]-'0'+1;
			count++;

		}
		cout <<fixed<< setprecision(1) << getScore << endl;
	}
	int maxOfAll=0;
	for (i = 0; i < M; i++)
	{
		int maxOption = *max_element(ques[i].options, ques[i].options+5);
		if (maxOption > maxOfAll)
			maxOfAll = maxOption;
	}
	if (maxOfAll == 0)
		cout << "Too simple" << endl;
	else
	{
		for (i = 0; i < M; i++)
		{
			for (j = 0; j < 5; j++)
			{
				if (ques[i].options[j] == maxOfAll)
					cout << maxOfAll << " " << i + 1 << "-" << char(j + 'a') << endl;
			}
		}
	}
	

    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值