Some classes have no more than 100 people (concrete Numbers from the keyboard input) take a certain course of examination, programming implementation, such as
Under the function of student achievement management system: (with a structure array)
(1) entry each student's student id, name and test scores;
(2) the calculation course of total peace divide;
(3) the output of each student's student id, name, the examination results;
(4) according to the results from high to low discharge league table; Sorting algorithm (self-study)
(5) by student number query students ranking and test scores,
Among them: (1), (2), (3) to do, (4), (5), encourage the calling function and file, implementation phase
The bonus should be content,
CodePudding user response:
Just some idle time, conveniently wrote, reference
# define _CRT_SECURE_NO_WARNINGS
#include
#include
# define N 100
Typedef struct student
{
Int ID;
char name[20];
double score;
} Student;
//input information
Void InputStudent (Student * stu, int n)
{
int i;
for (i=0; I & lt; n; I++)
{
Printf (" input the first % d student information: \ n ", I + 1);
The scanf (" % d % s % lf ", & amp; Stu [I]. ID, stu [I]. Name, & amp; Stu [I] score);
}
}
//calculate the total score
Double TotalSocre (Student * stu, int n)
{
Double sum=0.0;
int i;
for (i=0; I & lt; n; I++)
{
The sum +=stu [I] score;
}
Return the sum.
}
//output
Void PrintStudent (Student * stu, int n)
{
int i;
Printf (" student id name \ \ t t result \ n ");
for (i=0; I & lt; n; I++)
{
Printf (" % d \ \ t t % s % 2 f \ n ", stu [I] ID, stu [I]. Name, stu [I] score).
}
}
//order
Void SortStudent (Student * stu, int n)
{
int i, j;
Student TMP={0};
for (i=0; I & lt; n; I++)
{
for (j=0; J & lt; N - I - 1; J++)
{
If (stu [j] score & lt; Stu [j + 1] score)
{
TMP=stu [j];
Stu [j]=stu [j + 1);
Stu [j + 1)=TMP;
}
}
}
}
//by student number query
Void QueryScore (Student * stu, int n)
{
Int I, TMP;
Printf (" input to query student id: \ n ");
The scanf (" % d ", & amp; TMP);
for (i=0; I & lt; n; I++)
{
If (stu [I] ID==TMP)
{
Printf (" student id name \ \ t t result \ n ");
Printf (" % d \ \ t t % s % 2 f \ n ", stu [I] ID, stu [I]. Name, stu [I] score).
return;
}
}
Printf (" student id for % d students does not exist! \ n ", TMP);
}
Int main ()
{
int n;
Double sum, avge;
Student s [N]={0};
Printf (" input the number of students: \ n ");
The scanf (" % d ", & amp; N);
InputStudent (s, n);
Sum=TotalSocre (s, n);
Avge=sum/n.
Printf (" \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
PrintStudent (s, n);
Printf (" \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" scored an average score: % 2 f: %. 2 f \ n ", sum, avge);
Printf (" \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
SortStudent (s, n);
PrintStudent (s, n);
Printf (" \ n -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
QueryScore (s, n);
system("pause");
return 0;
}