标签:play http get src 思路 scanf type close display
1073 多选题常见计分法 (20分)
思路:
1.错选的和未选的都计入错误信息
2.错误信息的输出应该是 MAX某道题某选项的错误次数+题号+选项
首次通过代码:
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 typedef struct answer{ 6 int s_sum; 7 int r_s_sum; 8 int score; 9 int w_sum; 10 int right_answer[6]; 11 int wrong_answer[6]; 12 }answer,*a; 13 14 int main(){ 15 int student_sum; 16 int answer_sum; 17 scanf("%d %d",&student_sum,&answer_sum); 18 a answer_list[101]={NULL}; 19 for(int i=0;i<answer_sum;i++){ 20 a a1=(a)malloc(sizeof(answer));a1->w_sum=0; 21 for(int j=0;j<6;j++){ 22 a1->right_answer[j]=0; 23 a1->wrong_answer[j]=0; 24 } 25 scanf("%d %d %d",&a1->score,&a1->s_sum,&a1->r_s_sum); 26 for(int j=0;j<a1->r_s_sum;j++){ 27 char k[2]; 28 scanf("%s",k); 29 a1->right_answer[k[0]-‘a‘]=1; 30 } 31 answer_list[i]=a1; 32 } 33 getchar(); 34 int all_right=0; 35 for(int i=0;i<student_sum;i++){ 36 char input[1000];double s_score=0;int flag=1; 37 gets(input); 38 int counter=0;int j=0; 39 while(1){ 40 int k=input[j]-‘0‘; 41 if(k>=0&&k<=9) { 42 int c1=0,c2=0;int flag1=1; 43 while(1){ 44 int k=input[++j]-‘a‘; 45 if(k>=0&&k<=9){ 46 if(answer_list[counter]->right_answer[k]==1) { 47 c1++; 48 answer_list[counter]->wrong_answer[k]++; 49 } 50 else {answer_list[counter]->wrong_answer[k]++; 51 flag=0; 52 if(flag1){ 53 flag1=0; 54 answer_list[counter]->w_sum++; 55 } 56 c2++;} 57 } 58 else if(input[j]==‘)‘||input[j]==‘\0‘) break; 59 } 60 if(c1==answer_list[counter]->r_s_sum&&c2==0) s_score+=answer_list[counter]->score; 61 else if(c1<answer_list[counter]->r_s_sum&&c2==0) s_score+=0.5*(double)answer_list[counter]->score; 62 counter++; 63 } 64 if(counter==answer_sum||input[j]==‘\0‘) break; 65 j++; 66 } 67 if(flag&&counter==answer_sum) all_right++; 68 printf("%.1lf\n",s_score); 69 } 70 if(all_right==student_sum) { 71 printf("Too simple"); 72 return 0; 73 } 74 int max=0; 75 for(int i=0;i<answer_sum;i++) 76 for(int j=0;j<6;j++){ 77 if(answer_list[i]->right_answer[j]==1&&student_sum-answer_list[i]->wrong_answer[j]>max) 78 max=student_sum-answer_list[i]->wrong_answer[j]; 79 else if(answer_list[i]->right_answer[j]==0&&answer_list[i]->wrong_answer[j]>max) 80 max=answer_list[i]->wrong_answer[j]; 81 } 82 for(int i=0;i<answer_sum;i++){ 83 for(int j=0;j<6;j++){ 84 if(answer_list[i]->right_answer[j]==1&&student_sum-answer_list[i]->wrong_answer[j]==max) 85 printf("%d %d-%c\n",max,i+1,j+‘a‘); 86 else if(answer_list[i]->right_answer[j]==0&&answer_list[i]->wrong_answer[j]==max) 87 printf("%d %d-%c\n",max,i+1,j+‘a‘); 88 89 } 90 } 91 return 0; 92 }
标签:play http get src 思路 scanf type close display
原文地址:https://www.cnblogs.com/a982961222/p/12391927.html