zoukankan      html  css  js  c++  java
  • 1058 选择题 (20 分)

    pat_1058.jpg

    #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("
    ");//吃掉一个回车
    		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

  • 相关阅读:
    Flask之蓝图
    Flask之请求扩展
    Flask之flash
    Flask之session
    Flask之请求与响应
    Flask之模板系统
    Flask之路由系统
    Flask之配置文件
    Flask之快速入门
    Django项目 第一课 【nvm、node、npm安装及使用】
  • 原文地址:https://www.cnblogs.com/chance-zou/p/10456371.html
Copyright © 2011-2022 走看看