using namespace std;
Struct student {
Char id [10];
Char name [20].
Int score [4];
Double business;
};
Void input (student *, int);
Void sort (student *, int);
Void show (student *, int);
Int main ()
{int n;
Cout<" Please enter the number of students: ";
Cin> n;
Struct student * p=new struct student [n].
if(! P) {
Cout<" Allocation error! \ n ";
return 0;
}
Input (p, n);
Sort (p, n);
Show (p, n);
The delete [] p;
return 0;
}
Void input (student * s, int n)
{int I, j, sum=0;
For (I=0; i
Cout<" Please enter the first "& lt; Cin> S [I]. Name;
Cout<" Please enter the enter the first & lt;" for(int j=0; j<4. J++)
Cin> S [I] score [j];
for(j=0; j<4. J++)
The sum +=s [I] score [j];
S [I] business=sum/4;
Cout<" The first "& lt; }
}
Void sort (student * s, int n)
{int I, j;
Student temp.
for(j=0; j
S=s [I] [I + 1);
S=\ [I + 1];
}
}
Void show (student * s, int n)
{
Cout<" The average score sorting result to "& lt;
}
CodePudding user response:
for(j=0; j<4. J++)The sum +=s [I] score [j];
S [I] business=sum/4;
Cout<" The first "& lt;
Sum=0;//add it here, put the sum to zero, because a few students to statistics with the sum total, no return 0, the value of the sum of a student will be taken to the next student
//, in this case, the sum of the first students=10 + 10 + 10 + 10=40, then to receive the second student of 20 + 20 + 20 + 20=120, so the second
//a student's grade point average is 120/4=30
}