50175. Grading

I'm a slow walker, but I never walk backwards.

Task Description

This task is to calculate the scores of students according to their submissions. Each submission has the student ID who submitted it, a unique submission id, and ten outputs (as strings) from the program written by the student. You have to grade every submission according to ten correct answers (as strings) by strcmp. That is, the anwser given by the student must be exactly the same as the correct answer. The scores of a submission is the number of correct outputs multiplied by $10$. A student can submit more than once, and the student’s final score is the highest one among all his/her submissions. Please refer to the following example.

SubmissionsSubmissions

You need to print scores of all submissions in the order of the student's id. The submissions from the same student are in the order of the submission id. After printing all submissions of a student, you need to print the final score of this student. The printing format is as follows.

Student 1 gets 50 with Submission 25.
Student 1 gets 50 in this exam.
Student 4 gets 100 with Submission 23.
Student 4 gets 0 with Submission 24.
Student 4 gets 100 in this exam.

The Submission structure and the grading function is defined in grading.h as follow. In the grading function, ansewer are the 10 correct outputs, sub is a Submission structure pointer which point to the first of all submissions, and num_of_submission is the number of the submissions.

#define maxL 1000
typedef struct Submission
{
    int subID;
    int studentID;
    char outputs[10][maxL];   
}Submission;
void grading(char answer[10][maxL], Submission* sub, int num_of_submission);

You may use the following main.c to test your function.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "grading.h"
 
#define maxL 1000
 
int main(){
    char answer[10][maxL];
    int  num_of_submission;
    Submission* sub;
 
    for(int i=0;i<10;i++){
        scanf("%s",answer[i]);
    }
 
    scanf("%d",&num_of_submission);
 
    sub=(Submission*)malloc(num_of_submission*sizeof(Submission));
    for(int i=0;i<num_of_submission;i++){
        scanf("%d %d",&sub[i].subID,&sub[i].studentID);
        for(int j=0;j<10;j++){
            scanf("%s",sub[i].outputs[j]);
        }
    }
    grading(answer,sub,num_of_submission);
}

Input Format (for main.c)

The first 10 lines are 10 correct answer strings. The following line has the number of the submissions. The next 11 lines are for one submission. The first line has the submission id and the student id. The following ten lines are the outputs from the student program. Then the following 11 lines are for the next submission, and so on.

Output Format

Print the results of all submissions and the finale score for every student, according to the format above.

Sample Input

aa
bb
cc
dd
ee
ff
gg
hh
ii
jj
3
24 4
1a
2s
3d
4f
5q
6w
7e
8r
9z
10xc
23 4
aa
bb
cc
dd
ee
ff
gg
hh
ii
jj
25 1
aa
22b
cc
33d
ee
44ff
gg
hh
i23
jj32

Sample Output

Student 1 gets 50 with Submission 25.
Student 1 gets 50 in this exam.
Student 4 gets 100 with Submission 23.
Student 4 gets 0 with Submission 24.
Student 4 gets 100 in this exam.

Discussion