zoukankan      html  css  js  c++  java
  • PAT (Basic Level) Practice (中文) 1058 选择题 (20分) (复杂类型的scanf输入,getchar使用)

    1.题目

    批改多选题是比较麻烦的事情,本题就请你写个程序帮助老师批改多选题,并且指出哪道题错的人最多。

    输入格式:

    输入在第一行给出两个正整数 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
    

    2.代码

    #include<iostream>
    #include<string>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    struct node
    {
    	int score;
    	int right;
    	char answer[10];
    }list[1001];
    int main()
    {
    
    	int n, m,t;
    	int wrong[1001] = { 0 };
    	cin >> n >> m;
    	string temp;
    	for (int i = 0; i < m; i++)
    	{
    		scanf("%d%d%d", &list[i].score, &t, &list[i].right);
    		for (int j = 0; j < list[i].right; j++)
    			scanf(" %c", &list[i].answer[j]);
    	}
    	int tempscore = 0;
    	getchar();
    	for (int i = 0; i < n; i++)
    	{
    		tempscore = 0;
    		for (int j = 0; j < m; j++)
    		{
    			int b; char c; bool error = false;
    			scanf("(%d", &b);
    				for (int k = 0; k < b; k++)
    				{
    					scanf(" %c", &c);
    					if (list[j].answer[k] != c) {  error = true;}
    				}
    				getchar(); getchar();
    				if (b != list[j].right)wrong[j]++;
    				else if(error)wrong[j]++;
    				if (b == list[j].right&&!error)tempscore += list[j].score;
    		}
    		cout << tempscore << endl;
    	}
    	int max = -1;
    	for (int i = 0; i < m; i++)
    		if (max < wrong[i])max = wrong[i];
    	if (max == 0)cout << "Too simple" << endl;
    	else
    	{
    		cout << max;
    		for (int i = 0; i < m; i++)
    			if (wrong[i] == max)cout << ' ' << i + 1;
    	}
    }
  • 相关阅读:
    Kafka事务机制
    RabbitMQ事务机制
    RocketMQ事务消息
    No 'Access-Control-Allow-Origin' header is present on the requested resource.'Ajax跨域访问解决方案
    java + eclipse 工作环境快速配置
    查找.bashrc文件并设置linux快捷命令
    headers参数传值类型
    无需会员将有道云笔记脑图转换xmind
    使用goland调试远程代码
    nginx配置文件使用环境变量
  • 原文地址:https://www.cnblogs.com/Jason66661010/p/12788931.html
Copyright © 2011-2022 走看看