Current location - Quotes Website - Signature design - How to write the C language test report?
How to write the C language test report?
Experimental topic:

Enter the student numbers of one class 10 and the scores of three subjects (mathematics, English and computer basics) of each student. The program calculates the total score and average score of each student, sorts them according to their grades, and finally prints out the report cards sorted from high score to low score. Requirements:

1) sorting is realized by a function.

2) The printed report card items include: serial number, student number, mathematics, English, computer, total score and average score.

3) Fill in the experimental contents according to the electronic template format of the experimental report.

Experimental purpose

Source program list:

(source code after debugging)

# include & ltstdio.h & gt

# include & ltstdlib.h & gt

#define STU_NUM 10 /* Macro defines the number of students */

Structure student/* Define a structure to store students' student numbers, scores, total scores and average scores of three courses */

{

char stu _ id[20]; /* Student ID card; */

Floating score [3]; /* Three course scores; */

Floating total; /* Total score; */

Average value of floating aver/*; */

};

/* Sorting is realized by functions */

void SortScore(student *stu,int n)

{

Students study;

for(int I = 0; I<n-1; i++)

for(int j = I+ 1; j & ltn; j++)

{

If (Stu [I]. Total & lt Stu [j]. Total)

{

stud = stu[I];

stu[I]= stu[j];

stu[j]= stud;

}

}

}

int main()

{

Student stu [stu _ num]; /* There are 10 elements in the structure array created, which are used to store the related information of this 10 person. */

/* Enter the relevant information of these ten students */

for(int I = 0; I & ltSTU _ NUMi++)

{

Printf ("Please enter the student number of %d:", I+1);

Scanf("%s ",& Stu [me]. stu _ id);

Printf ("Enter the math scores of %d students:", I+1);

Scanf("%f ",& Stu [me]. Score [0]);

Printf ("Enter English scores of %d students:", I+1);

Scanf("%f ",& Stu [me]. Score [1]);

Printf ("Enter the computer scores of %d students:", I+1);

Scanf("%f ",& Stu [me]. Score [2]);

Stu [me]. total = stu[i]。 score[0]+stu[i]。 score[ 1]+stu[i]。 Score [2];

Stu [me]. aver = stu[i]。 Total/3;

}

printf(" \ n ");

Sorting score (stu, stu _ num); /* Call sorting function */

/* Output the sorted student scores */

for(I = 0; I & ltSTU _ NUMi++)

{

Printf ("serial number: %d\t", i);

Printf ("Student ID: %s\t", stu[i]. stu _ id);

Printf ("Math: %f\t ",stu[i]。 Score [0]);

Printf ("English: %f\t", stu[i]. Score [1]);

Printf ("computer: %f\t", stu[i]. Score [2]);

Printf ("GPA: %f\t ",stu[i]。 aver);

Printf ("total score: %f\t", stu[i]. Total);

printf(" \ n \ n ");

}

Returns 0;

}

Description of the main identifier:

(Description of the main identifier in the source program)

#define STU_NUM 10 /* Macro defines the number of students */

Structure student/* Define a structure to store students' student numbers, scores, total scores and average scores of three courses */

{

char stu _ id[20]; /* Student ID card; */

Floating score [3]; /* Three course scores; */

Floating total; /* Total score; */

Average value of floating aver/*; */

};