The specific requirements
(1) in the main function of the correct input each student's student id and two subjects (input can be according to the different situation with different input method),
Requirement: the tooltip is necessary input to
(2) the design of each sub function of each student's final grade in all subjects, the total stored in arrays,
(3) the design and the function of average score for each course, and each grade average in stored in arrays,
CodePudding user response:
A piece of code for reference
#include
#include
# define M 5
# define N 3
Typedef struct student
{
Int studID.
Char name [20].
Float score1.
Float score2;
Float score3;
} STU.
//enter
Void InputSTU (STU * arr, int n)
{
int i;
for (i=0; i{
Printf (" input the first % d a student's student id name subject a subject two subjects three grades: \ n ", I + 1);
The scanf (" % d % s % f % f % f ", & amp; Arr [I]. StudID, arr [I]. Name, & amp; Arr [I]. Score1, & amp; Arr [I]. Score2,
& Arr [I] score3);
}
Printf (" input is complete, press any key to continue... \n");
getchar();
}
//total score
Void TotalScore (STU * arr, float * TotalArr, int n)
{
int i;
for (i=0; i{
TotalArr [I]=arr [I] score1 + arr [I] score2 + arr [I] score3;
}
Printf (" calculation is complete, press any key to continue... \n");
getchar();
}
//average
Void AverageScore (STU * arr, float * AverageArr, int n)
{
int i;
Float sum1=0, sum2=0, sum3=0;
for (i=0; i{
Sum1 +=arr [I] score1.
Sum2 +=arr [I] score2;
Sum3 +=arr [I] score3;
}
AverageArr [0]=sum1/M;
AverageArr [1]=sum2/M;
AverageArr [2]=sum3/M;
Printf (" calculation is complete, press any key to continue... \n");
getchar();
}
Int main ()
{
int i;
STU stud [M].
Float Total [M]={0};
Float business [N]={0};
InputSTU (stud, M);
TotalScore (stud, Total, M);
Printf (" \ n student id a \ t \ \ t t name subject course 2 \ t course three \ t \ n total score ");
for (i=0; i{
Printf (" % d \ \ t t % s % 2 f \ t % 2 f \ t % 2 f \ t % 2 f \ n ", stud [I] studID, stud [I]. Name,
Stud [I]. Score1, stud [I] score2, stud [I] score3, Total [I]);
}
AverageScore (stud, business, M);
for (i=0; i{
Printf (" subjects scored an Average % d: % 2 f \ n ", I + 1, business, [I]);
}
getchar();
return 0;
}