# include & lt; stdio.h>
# include
/* structure definition students */
Struct Student
{
Char ID [20];
Char Name [20].
Float Mark1;
Float Mark2;
Float Mark3.
Float Mark4;
Float Mark5;
Float business;
};
/* array declaration students and student number */
Struct Student students [1000].
int num=0;
/* averaging */
Float Avg (struct Student stu)
{
Return ((stu. Mark1 + stu. Mark2 + stu. Mark3 + stu. Mark4 + stu. Mark5)/5);
}
Returns an array subscript *//* by student number
Int Student_SearchByIndex (char id [])
{
int i;
for (i=0; I{
If (STRCMP (students [I] ID, ID)==0)
{
return i;
}
}
return -1;
}
Returns an array subscript *//* by name
Int Student_SearchByName (char name [])
{
int i;
for (i=0; I{
If (STRCMP (students [I]. Name, Name)==0)
{
return i;
}
}
return -1;
}
/* shows a single student record */
Void Student_DisplaySingle (int index)
{
Printf (" % s % 10 s 8 8 8 s % % s % s % s \ n ", "student id", "name", "grade 1", "grade 2", "three grade", "grade 4", "grade 5," "gpa");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - \ n ");
Printf (" % s % s % 8.2 f % 8.2 f % 8.2 f % 10.2 f \ n ", students [index]. ID, students [index]. Name,
Students [index]. Mark1, students [index] Mark2, students [index] Mark3, students [index] Mark4, students [index] Mark5, students [index] business);
}
/* insert student information */
Void Student_Insert ()
{
While (1)
{
Printf (" please enter the student id: ");
The scanf (" % s ", & amp; Students (num). ID);
getchar();
Printf (" please input your name: ");
The scanf (" % s ", & amp; Students (num). Name);
getchar();
Printf (" please enter the grade 1: ");
The scanf (" % f ", & amp; Students [r]. Num Mark1);
getchar();
Printf (" please enter the grade 2: ");
The scanf (" % f ", & amp; Students [r]. Num Mark2);
getchar();
Printf (" please enter the grade 3: ");
The scanf (" % f ", & amp; Students [r]. Num Mark3);
getchar();
Printf (" please enter the grade 4: ");
The scanf (" % f ", & amp; Students [r]. Num Mark4);
getchar();
Printf (" please enter the grade 5: ");
The scanf (" % f ", & amp; Students [r]. Num Mark5);
getchar();
Students [num] business=Avg (students (num));
num++;
Printf (" whether to continue? (y/n) ");
If (getchar ()=='n')
{
break;
}
}
}
/* * modify the students information/
Void Student_Modify ()
{
//float mark1, mark2 mark3;
While (1)
{
Char id [20];
Int index;
Printf (" please input to modify the student's student id: ");
The scanf (" % s ", & amp; id);
getchar();
The index=Student_SearchByIndex (id);
If (index==1)
{
Printf (" the student does not exist! \n");
}
The else
{
Printf (" do you want to modify the information of students is: \ n ");
Student_DisplaySingle (index);
Printf (" please enter a new value - \ n ");
Printf (" please enter the student id: ");
The scanf (" % s ", & amp; Students [index]. ID);
getchar();
Printf (" please input your name: ");
The scanf (" % s ", & amp; Students [index]. Name);
getchar();
Printf (" please enter the grade 1: ");
The scanf (" % f ", & amp; Students [index] Mark1);
getchar();
Printf (" please enter the grade 2: ");
The scanf (" % f ", & amp; Students [index] Mark2);
getchar();
Printf (" please enter the grade 3: ");
The scanf (" % f ", & amp; Students [index] Mark3);
getchar();
Printf (" please enter the grade 4: ");
The scanf (" % f ", & amp; Students [index] Mark4);
getchar();
Printf (" please enter the grade 5: ");
The scanf (" % f ", & amp; Students [index] Mark5);
getchar();
Students [index]. Business=Avg (students [index]);
}
Printf (" whether to continue? (y/n) ");
If (getchar ()=='n')
{
break;
}
}
}
/* */delete student information
Void Student_Delete ()
{
int i;
While (1)
{
Char id [20];
Int index;
Printf (" please enter the student's student id: to delete ");
The scanf (" % s ", & amp; id);
getchar();
The index=Student_SearchByIndex (id);
If (index==1)
{
Printf (" the student does not exist! \n");
}
The else
{
Printf (" you want to delete student information for: \ n ");
Student_DisplaySingle (index);
Printf (" really want to delete? (y/n) ");
If (getchar ()=='y')
{
For (I=index; I{
Students [I]=students [I + 1);//all the objects behind forward
}
Num -;
}
getchar();
}
Printf (" whether to continue? (y/n) ");
If (getchar ()=='n')
{
break;
}
}
}
/* by name query */
Void Student_Select ()
{
While (1)
{
Char name [20].
Int index;
Printf (" please enter the names of the students to query: ");
The scanf (" % s ", & amp; Name);
getchar();
The index=Student_SearchByName (name);
If (index==1)
{
Printf (" the student does not exist! \n");
}
The else
{
Printf (" do you want to query student information for: \ n ");
Student_DisplaySingle (index);
}
Printf (" whether to continue? (y/n) ");
If (getchar ()=='n')
{
break;
}
}
}
/* sort by average */
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull