【PAT】B1073 多选题常见计分法(20 分)

此处为我的存储结构,只提供一种思路,二维数组存储所有数据
我的存储结构

#include<stdio.h>
#include<string.h>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int ti[200][20]={0};
bool ffind(char *p,char c){
	int len = strlen(p);
	for(int i=0;i<len;i++){
		if(p[i]==c) return true;
	}
	return false;
}
int main(){
	int flag=0;//储存错的最多次数
	int N,M;scanf("%d %d",&N,&M);
	for(int i=1;i<=M;i++){
		scanf("%d %d %d",&ti[i][0],&ti[i][1],&ti[i][2]);
		for(int j=0;j<ti[i][2];j++){
			char temp;scanf(" %c",&temp);
			ti[i][temp-'a'+3]=1;
		}
	}
	getchar();//接收换行
	for(int i=0;i<N;i++){//N个学生,N次循环
		double score=0;//当前学生成绩
		for(int j=1;j<=M;j++){
			int Tnum=0,ff=0;
			char str[10];
			scanf(" (%[^)]",str);
 			for(int k=3;k<=7;k++){
				char temp=k-3+'a';
				if(ffind(str,temp)==true){//选了
					if(ti[j][k]==0){//错
						ti[j][k+5]++;ff=1;
						if(ti[j][k+5]>flag) flag=ti[j][k+5];
					}else Tnum++;
				}else{//没选
					if(ti[j][k]==1){
						ti[j][k+5]++;
						if(ti[j][k+5]>flag) flag=ti[j][k+5];
					}
				}
			}
			if(ff==0){
				if(Tnum==ti[j][2]) score+=ti[j][0];
				if(Tnum<ti[j][2]){
					score+=ti[j][0]/2.0;
				}
			}
			getchar();//右括号
		}
		printf("%.1lf\n",score);
	}
	if(flag==0){
		printf("Too simple");
		return 0;
	}
	for(int i=1;i<=M;i++){
		for(int j=8;j<=12;j++){
			if(ti[i][j]==flag) printf("%d %d-%c\n",flag,i,j-8+'a');
		}
	}
	return 0;
}

posted @ 2018-08-17 08:45  路明天  阅读(457)  评论(0编辑  收藏  举报