1058 选择题 (20分)详细代码 过程有点繁琐,但是整体思路很清晰

#include <iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
struct question {
	int num;//题目编号
	int score;//题目分数
	int choice_num;//题目所有选项个数
	int wrong_time=0;//错误次数
	char c[20];
};
question q[101];
int s[1001] = {0};//学生分数数组
char a[2000],k[200];
bool cmp(question x, question y){
	if (x.wrong_time <=y.wrong_time)
		return false;
	else
		return true;
}
int main()
{
	bool flag = true,flag2=true;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		q[i].num = i+1;
		cin >> q[i].score >> q[i].choice_num ;
		char ch = getchar();
		cin.getline(q[i].c, 20);
	}
	for (int i = 0; i < n; i++) {
		int left = 0, right = 0,g=0;
		cin.getline(a, 2000);
		for (int j = 0; j < strlen(a); j++) {
			if (a[j] == '(')
				left++;
			if (a[j] != '('&&a[j] != ')') {
				k[g] = a[j];
				g++;
			}
			if (a[j] == ')') {
				j++;
				k[g] = '\0';
				if (strcmp(q[right].c, k) == 0)
					s[i] = s[i] + q[right].score;
				else {
					q[right].wrong_time++;
					flag = false;
				}
				g = 0;
				k[0] = '\0';
				right++;
			}
		}
	 }
	for (int i = 0; i < n; i++)
		cout << s[i] << endl;
	if (flag) {
		cout << "Too simple";
		return 0;
	}
	sort(q, q + m, cmp);
	cout << q[0].wrong_time<<" "<<q[0].num;
	for (int i = 1; i < m; i++) {
		if (q[i].wrong_time == q[0].wrong_time) {
			cout << " " << q[i].num;
		}
	}

}

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值