首页 > 其他 > 详细

1058 选择题 (20 分)

时间:2019-03-01 15:55:44      阅读:227      评论:0      收藏:0      [点我收藏+]

技术分享图片

#include <iostream>
#include<string>
using namespace std;
typedef struct {
    int score;//该题分数
    int num;//选项个数
    int right;//正确选项个数
    string str="";//正确选项
}question[100];
int main()
{
    int stu, que;
    question a;
    cin >> stu >> que;//学生人数和问题数
    for (int i = 0;i < que;i++) {
        cin >> a[i].score >> a[i].num >> a[i].right;
        for (int j = 0;j < a[i].right;j++){
            char c;
            cin >> c;
            a[i].str += c;//尾接法
        }
    }
    int wrong[100] = { 0 };
    for (int i = 0;i < stu;i++) {
        int defen = 0;
        scanf("\n");//吃掉一个回车
        for (int j = 0;j < que;j++) {
            if (j != 0)scanf(" ");
            int k;
            string b = "";
            scanf("(%d", &k);//用scanf()控制输入格式
            for (int m = 0;m < k;m++) {
                char c;
                scanf(" %c", &c);
                b = b + c;//尾接法
            }
            scanf(")");
            if (b==a[j].str) {
                defen += a[j].score;
            }
            else {
                wrong[j]++;
            }
        }
        cout << defen << endl;
    }
    //找出错的最多的题目的错误次数
    int max = 0;
    for (int i = 0;i < que;i++) {
        if (wrong[i] > max) {
            max = wrong[i];
        }
    }
    if (max == 0) {
        cout << "Too simple" << endl;
    }
    else {
        cout << max;
        for (int i = 0;i < que;i++) {
            if (wrong[i] == max) {
                cout << " " << i + 1;
            }
        }
    }
    return 0;
}

参考博客:https://blog.csdn.net/liuchuo/article/details/52510582

1058 选择题 (20 分)

原文:https://www.cnblogs.com/chance-zou/p/10456371.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!