Home > Back-end >  New people for help
New people for help

Time:06-08

Examination paper analysis
Write a test paper analysis program, the topic number between 5 and 50, the test number in the 30 or so, the program from a group called examdat. TXT file to read the test information, examdat. The first line of the TXT file records the number of questions and the standard answer, starting from the second line recorded every student to take an examination of the student id and took, the answer,
Examdat. TXT sample content as follows:
5 dbbac
111 dabac
102 DCBDC
251 dbbac

The program after receiving input to output a examination paper analysis report, called the report. TXT file, the examination paper analysis consists of three parts: the first part is the standard answer, the second part is each student's score, the third part is the error rate of each subject,
The Report. TXT sample is as follows:
Exam Report
Question 1, 2, 3, 4, 5
Answer b a b c d
ID Score (%)
111, 80,
60 102
251, 100,
Question 1, 2, 3, 4, 5
Missed by 2 0 0 0 1

CodePudding user response:

 
/* -
* Copyright (C), 1999-2019, mymtom.
* _
* ____ _ _ ____ _ | | _ _____ _____
* | \ | | | | (_ _) _ \ | \
* | | | | | _ | | | | | | | | | _ | | | | |
* | _ | _ _ - | | \ | _ | _ _ - | | \ () ___/| _ | _ | _ |
* (____/
*
* https://bbs.csdn.net/topics/395050626
*/

/* *
C
* @ file ExamReport.* @ brief,
*/

#include
#include

# define MAX_EXAMINEE_COUNT 100
# define MAX_QUESTION_COUNT 50

Typedef struct _ExamDat {
Int number;
Char answer [MAX_QUESTION_COUNT + 1];
} ExamDat;

Int
ReadExamDat (FILE * stream, ExamDat * answers, int size)
{
int count=0;
While (the count & lt; The size
& & Fscanf (stream, "% d % s",
& Answers [r]. The count number,
Answers [count] answer)==2) {
Printf (" % 4 d | % s \ n ", answers [r]. The count number, answers [count] answer);
count++;
}
return count;
}

The static void
PrintReport (const ExamDat * standardAnswer, const ExamDat * examineeAnswers, int count)
{
int i, j;
int score;
Int missed [MAX_QUESTION_COUNT]={0};

Fprintf (stdout, "Exam Report \ n");

Fprintf (stdout, "Question");
For (j=0; J & lt; StandardAnswer - & gt; Number; J++)
Fprintf (stdout, "% 2 d", j + 1);
Fprintf (stdout, "\ n");

Fprintf (stdout, "Answer");
For (j=0; J & lt; StandardAnswer - & gt; Number; J++)
Fprintf (stdout, the "% c", standardAnswer - & gt; Answer [j]);
Fprintf (stdout, "\ n");


Fprintf (stdout, "ID Score (%) \ n");
For (I=0; I & lt; The count. I++) {
Score=0;
For (j=0; J & lt; StandardAnswer - & gt; Number; J++) {
If (standardAnswer - & gt; Answer [j]==examineeAnswers [I] answer [j]) {
Score++;
} else {
Missed [j] + +;
}
}
Fprintf (stdout, "\ n % 3 d % d", examineeAnswers [I] number, score * 100/standardAnswer - & gt; Number);
}

Fprintf (stdout, "Question");
For (j=0; J & lt; StandardAnswer - & gt; Number; J++)
Fprintf (stdout, "% 2 d", j + 1);
Fprintf (stdout, "\ n");

Fprintf (stdout, "Missed by");
For (j=0; J & lt; StandardAnswer - & gt; Number; J++)
Fprintf (stdout, "% 2 d", missed [j]);
Fprintf (stdout, "\ n");

}

Int
The main (void)
{
int count;
ExamDat standardAnswer;
ExamDat * examineeAnswers=calloc (MAX_EXAMINEE_COUNT, sizeof (ExamDat));

ReadExamDat (stdin, & amp; StandardAnswer, 1);
Count=readExamDat (stdin, examineeAnswers MAX_EXAMINEE_COUNT);

PrintReport (& amp; StandardAnswer examineeAnswers, count);
Free (examineeAnswers);
return 0;
}

CodePudding user response:


I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related