1, Function: Enter 6 Student's 5 course result, calculate each student's average score and each course's average score.
2, C language Implementation code: (In fact, is the use of two-dimensional arrays to implement, the two-dimensional array of reference transfer using the array pointer to complete)
Copy Code code as follows:
#include <stdio.h>
#define STUDENT 5
#define SCORE 6
void Input_array (float (*score) [STUDENT]);
void Avg_score (float (*score) [STUDENT]);
void Avg_course (float (*score) [STUDENT]);
/**
* Calculate student average score and course average.
*/
int main () {
float a[score][student];
Input_array (a);
Avg_course (a);
Avg_score (a);
}
void Input_array (float (*score) [STUDENT]) {
int I, J;
For (i=0 i<score; i++) {
printf ("Input the%d student score:", i+1);
For (j=0 j<student; j + +) {
scanf ("%f", Score[i] + j);
}
}
}
void Avg_course (float (*score) [STUDENT]) {
int i,j;
float S;
For (j=0 j<student; j + +) {
printf ("course%d", j);
}
printf ("\ n");
For (i=0 i<score; i++) {
s=0;
For (j=0 j<student; j + +) {
printf ("%f", * (Score[i] + j));
S + + * (Score[i] + j);
}
printf ("\ts=%f, avg=%f\n", s,s/student);
}
}
void Avg_score (float (*score) [STUDENT]) {
int i,j;
float S;
For (i=0 i<student; i++) {
s = 0;
for (j=0; j<score;j++) {
s+= * (score[j]+i);
}
printf ("%f", S/score);
}
}