PTA 乙级 1073 多选题常见计分法

特别注意一点,最后一个测试点给出的学生回答中会有非法字符!!!
所以只有用switch语句(仅限我的方法)。

代码实现:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct
{
	int score, choice_number, right_number, wrong_choice[5];
	char answer[15];
}question;

int main()
{
	int N, M;
	question *array;

	scanf("%d %d", &N, &M);
	array = (question*)malloc(sizeof(question)*M);
	for (int i = 0; i < M; i++)
	{
		scanf("%d %d %d", &array[i].score, &array[i].choice_number, &array[i].right_number);
		getchar(); gets(array[i].answer); 
		for (int j = 0; j < 5; j++)
			array[i].wrong_choice[j] = 0;
	}
	for (int i = 0; i < N; i++)
	{
		double score = 0;
		for (int j = 0; j < M; j++)
		{
			int num, count = 0;
			char answer[15], ch;
			scanf("(%d", &num); getchar();
			if (i != 0 || j != 0)
				getchar(), getchar(), getchar();
			while ((ch = getchar()) != ')')
				answer[count++] = ch;
			answer[count] = 0;
			if (strcmp(array[j].answer, answer) == 0)
				score += array[j].score;
			else
			{
				int flag1, flag2 = 0;
				for (int k = 0; answer[k] != 0; k++)
				{
					flag1 = 0;
					for (int p = 0; array[j].answer[p] != 0; p++)
						if (array[j].answer[p] == answer[k])
						{
							flag1 = 1; break;
						}
					if (flag1 == 0)
					{
						flag2 = 1;
						switch (answer[k])
						{
							case 'a':array[j].wrong_choice[0]++; break;
							case 'b':array[j].wrong_choice[1]++; break;
							case 'c':array[j].wrong_choice[2]++; break;
							case 'd':array[j].wrong_choice[3]++; break;
							case 'e':array[j].wrong_choice[4]++; break;
						}
					}
				}
				for (int k = 0; array[j].answer[k] != 0; k++)
				{
					flag1 = 0;
					for (int p = 0; answer[p] != 0; p++)
						if (array[j].answer[k] == answer[p])
							flag1 = 1;
					if (flag1 == 0)
						switch (array[j].answer[k])
						{
							case 'a':array[j].wrong_choice[0]++; break;
							case 'b':array[j].wrong_choice[1]++; break;
							case 'c':array[j].wrong_choice[2]++; break;
							case 'd':array[j].wrong_choice[3]++; break;
							case 'e':array[j].wrong_choice[4]++; break;
						}
				}
				if (flag2 == 0)
					score += (double)array[j].score / 2;
			}
		}
		printf("%.1f\n", score);
	}
	int max = array[0].wrong_choice[0];
	for (int i = 0; i < M; i++)
		for (int j = 0; j < 5; j++)
			if (max < array[i].wrong_choice[j])
				max = array[i].wrong_choice[j];
	if (max == 0)
		printf("Too simple");
	else 
		for(int i=0;i<M;i++)
			for(int j=0;j<5;j++)
				if (array[i].wrong_choice[j] == max)
					printf("%d %d-%c\n", max, i + 1, 'a' + j);
				

	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值