Home > Back-end >  Small white, homework to write their own uneasy, seek a solution
Small white, homework to write their own uneasy, seek a solution

Time:09-15

Input 10 students score 5 class, each function is used to implement the following functions:

(1) calculate each student's score;

(2) calculating the average of each course;

(3) to find out all 50 score the highest scores of the students and courses,

CodePudding user response:

To do it with a structure array

CodePudding user response:

reference 1st floor CHXCHXKKK response:
do it with a structure array

Wrote a reference
 
#include
using namespace std;

Const int N=3;

Typedef struct Stud
{
Char name [20].
Float score [5], business;
} STU.

//input result
Void InputSTU (STU * array, int n)
{
Int I, j;
Float temp=0;
For (I=0; i{
Cout & lt; <"Enter the first" & lt; Cout & lt; <"A student named course a second course three courses four five grades:" & lt; Cin & gt;> Array [I]. Name;
For (j=0; j<5; J++)
{
Cin & gt;> Array [I] score [j];
Temp +=array [I] score [j];
}

Array [I] business=temp/5;
Temp=0;
}
}

//output
Void PrintSTU (STU * array, int n)
{
Int I, j;
Cout & lt; For (I=0; i{
Cout & lt; For (j=0; j<5; J++)
{
Cout & lt; }
Cout & lt;
}
Cout & lt; }

//minute class average
Void ScoreAver (STU * array, int n)
{
Float aver [5]={0};
Int I, j;
For (j=0; j<5; J++)
{
For (I=0; i{
Aver [j] +=array [I] score [j];
}

}
Cout & lt; Cout & lt; <"Class a" & lt; <"\ t" & lt; <"Class 2" & lt; <"\ t";
Cout & lt; <"Course" & lt; <"\ t" & lt; <"The four courses" & lt; <"\ t";
Cout & lt; <"Course five" & lt;
For (I=0; i<5; I++)
{
Cout & lt; }
Cout & lt; }

//the highest
Void MaxSTU (STU * array, int n)
{
Int I, j, index_i index_j;
Float smax.
Smax=array [0]. Score [0].
For (I=0; i{
For (j=0; j<5; J++)
{
If (smax & lt; Array [I] score [j])
{
Smax=array [I] score [j];
Index_i=I;
Index_j=j;
}
}
}

Cout & lt; Cout & lt; Cout & lt; }

Int main ()
{
STU sArr [N].
InputSTU (sArr, N);
PrintSTU (sArr, N);
ScoreAver (sArr, N);
MaxSTU (sArr, N);


return 0;
}

CodePudding user response:

Read blogs, and the interpretation of, a very detailed answer
  • Related