1. Calculate the average score of the first course;
2. Find out the students who fail to pass more than two courses, and output the student ID and the group's non-course scores and average scores;
3. Find out the students whose average score is over 90 or all of their course scores are above 85;
# Include <stdio. h>
Int main ()
{
Void avsco (float *, float *);
Void avcour1 (char (*) [10], float *);
Void fail2 (char course [5] [10], int num [], float * pscore, float aver [4]);
Void good (char course [5] [10], int num [4], float * pscore, float aver [4]);
Int I, j, num [4], * pnum; // The number is an integer;
Float score [4] [5], * pscore, * paver, or aver [4]; // The score is float data;
Char (* pcourse) [10], course [5] [10];
Printf ("Please input course:/N ");
Pcourse = course;
For (I = 0; I <5; I ++)
Scanf ("% s", & course [I]);
Printf ("input no. and score:/N ");
Printf ("no .");
For (I = 0; I <5; I ++)
Printf (", % s", course [I]);
Printf ("/N ");
Pnum = & num [0];
Pscore = & score [0] [0];
For (I = 0; I <4; I ++)
{
Scanf ("% d", pnum + I); // This is the number of each person; only four values are required; therefore, they can only be placed here;
For (j = 0; j <5; j ++)
Scanf ("% F", pscore + 5 * I + J); // The score must be 20 values;
}
Paver = & aver [0];
Printf ("/n ");
Avsco (pscore, paver );
Avcour1 (pcourse, pscore );
Printf ("/n ");
Fail2 (pcourse, pnum, pscore, paver );
Printf ("/n ");
Good (pcourse, pnum, pscore, paver );
Return 0;
}
Void avsco (float * pscore, float * paver)
{
Int I, J;
Float sum, average;
For (I = 0; I <4; I ++)
{Sum = 0.0;
For (j = 0; j <5; j ++)
Sum = sum + (* (pscore + 5 * I + J); // in this equation, * (pscore + 5 * I + J) must be enclosed in parentheses;
Average = sum/5;
* (Paver + I) = average;
}
}
// Char (* pcourse) [10] cannot be written as * (pcourse) [10] here; otherwise, the link is seriously incorrect;
Void avcour1 (char (* pcourse) [10], float * pscore) // The declaration here is not Char course [5] [10], but Char (* pcousre) [10]);
{
Int I;
Float sum, average1;
Sum = 0.0; // sum needs to be initialized to 0.0;
For (I = 0; I <4; I ++)
Sum = sum + (* (pscore + 5 * I ));
Average1 = sum/4;
Printf ("the first course % s average score is % F", * pcourse, average1 );
}
Void fail2 (char course [5] [10], int num [], float * pscore, float aver [4]) // use the array pointer course [I], therefore, char * (pcourse) [10] cannot be used;
{
Int I, J, K, label;
Printf ("========================= student who is fail in Two Couses ================== =========/N ");
Printf ("no .");
For (I = 0; I <5; I ++)
Printf ("% 11 s", course [I]); // the char * (pcourse) [10] cannot be declared because the course name must be output using course [I]; only char course [5] [10];
Printf ("average/N ");
For (I = 0; I <4; I ++)
{Label = 0; // The course count of everyone who fails;
For (j = 0; j <5; j ++)
If (* (pscore + 5 * I + J) <60) label ++;
If (Label> = 2) // you can only output the score and average score of each person in label> = 2;
{
Printf ("% d", num [I]);
For (k = 0; k <5; k ++)
Printf ("% 11.2f", * (pscore + 5 * I + k); // outputs the course score of this person;
Printf ("% 11.2f", aver [I]); // because the average score has been calculated and saved in aver [I]; therefore, the Declaration applies to aver [4];
}
}
}
Void good (char course [5] [10], int num [4], float * pscore, float aver [4])
{
Int I, j, k, n;
Printf ("===================== students whose score is good ===========/N ");
Printf ("no .");
For (I = 0; I <5; I ++)
Printf ("% 11 s", course [I]);
Printf ("average/N ");
For (I = 0; I <4; I ++)
{N = 0; // The score of each person is greater than 85. The initial value is 0;
For (j = 0; j <5; j ++)
If (* (pscore + 5 * I + J)> 85) n ++;
If (n = 5) | (aver [I]> 90) // note that brackets are required for aver [I]> 90; (aver [I]> 90) Find the students whose scores are greater than 85 per course or whose average score is greater than 90;
{Printf ("% d", num [I]);
For (k = 0; k <5; k ++)
Printf ("% 11.2f", * (pscore + 5 * I + k ));
Printf ("% 11.2f/N", aver [I]); // It cannot be added with {} brackets with the previous sentence; otherwise, it is incorrect;
}
}
}