# include
# include
# include
Int readstudents (struct students stu []);//read the student information
Int readsexcode (struct sexcode sex []);//read the gender code
Int readcollegecode (struct collegecode colle []);//read college code
Void the transform (struct students stu [], struct sexcode sexy [], struct collegecode colle [], int a, b int, int) c;//enter
Void namesort (struct students stu [], int a);//sorted by name
Void averagesort (struct students stu [], int a);//average sort
Void searchcollege (struct students stu [], int a);//search according to the college student
Void namesearch (struct students stu [], int a);//by name search
Void printstudent (struct students stu [], struct sexcode sex [], struct collegecode colle [], int a, b int, int) c;//output
Void change (struct students stu [], int a);
Int passwordfun ();
Void passwordchange ();
Void averagefun (struct students stu [], int a);
Struct students {
int num;
char name[20];
Int sexnum;
Char sex [4];
Int collegenum;
Char college [20].
Int score [10].
Float business;
};
Struct sexcode {
Int sexnum;
Char sex [4];
};
Struct collegecode {
Int collegenum;
Char college [20].
};
Int main ()
{
Int a, b, c;
Int choice;
Struct students stu [100].
Struct sexcode sexy [2].
Struct collegecode colle [10].
Int t=passwordfun ();
If (t==0) {
Printf (" please use the correct password to log in program! \n");
return 0;
}
While (1) {
system("cls");
Printf (" * * * * * * * * * * * * * * * * student achievement system menu \ n * * * * * * * * 1. Sort by name, output \ n * * 2. According to the average grades of sorting, output * \ n * 3. The output for a given college students * \ n * 4. To modify a given student achievement information * \ n * 6. The name query students, output * \ n * 7. Delete student achievement * \ n * 8. Modify the system password * * 0. \ n \ n to return to the higher level menu * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
}
}
Int readstudents (struct students stu [])//read the student information
{
int i=0;
FILE *fp;
Fp=fopen (" D: \ \ ABC \ \ Student_Info TXT ", "r +");
If (fp==0) {
Printf (" can not open this file \ n ");
The exit (0);
}
The fscanf (fp, "% d", & amp; Stu [I] num);
while(! The feof (fp)) {
Fscanf (fp, "% s % d % d", stu [I]. Name, & amp; Stu [I]. Sexnum, & amp; Stu [I] collegenum);
For (int j=0; J & lt; 10; J++) {
The fscanf (fp, "% d", & amp; Stu [I] score [j]);
}
i++;
The fscanf (fp, "% d", & amp; Stu [I] num);
}
fclose(fp);
return i;
}
Int readsexcode (struct sexcode sexy [])//read the student gender information
{
int i=0;
FILE *fp;
Fp=fopen (" D: \ \ ABC \ \ S_Info TXT ", "r");
If (fp==0) {
Printf (" can not open this file \ n ");
The exit (0);
}
The fscanf (fp, "% d", & amp; Sexy [I] sexnum);
while(! The feof (fp)) {
Fscanf (fp, "% s", sexy [I] sex);
i++;
The fscanf (fp, "% d", & amp; Sexy [I] sexnum);
}
fclose(fp);
return i;
}
Int readcollegecode (struct collegecode colle [])//read college students information
{
int i=0;
FILE *fp;
Fp=fopen (" D: \ \ ABC \ \ C_Info TXT ", "r");
If (fp==0) {
Printf (" can not open this file \ n ");
The exit (0);
}
The fscanf (fp, "% d", & amp; Colle [I] collegenum);
while(! The feof (fp)) {
Fscanf (fp, "% s", colle [I] college);
i++;
The fscanf (fp, "% d", & amp; Colle [I] collegenum);
}
fclose(fp);
return i;
}
Void averagefun (struct students stu [], int a)//average
{
for(int i=0; i Int sum=0;
For (int j=0; J & lt; 10; J++) {
Sum=sum + stu [I] score [j];
}
Stu [I] business=1.0 * sum/10;
}
return ;
}
Void namesort (struct students stu [], int a)//sort by name
{
for(int i=0; i For (int j=I + 1; J & lt; A; J++) {
If (STRCMP (stu [I]. Name, stu [j]. Name) & lt; 0 {
Struct students temp=stu [I];
Stu [I]=stu [j];
Stu [j]=temp;
}
}
}
return ;
}
Void averagesort (struct students stu [], int a)//sort by average
{
for(int i=0; i For (int j=I + 1; J & lt; A; J++) {
If (stu [I] business & lt; Stu [j]. Journal of business) {
Struct students temp=stu [I];
Stu [I]=stu [j];
Stu [j]=temp;
}
}
}
return ;
}
Void printstudent (struct students stu [], struct sexcode sexy [], struct collegecode colle [], int a, b int, int) c//output information
{
for(int i=0; i Printf (" % d % s % 4 s % s "12, stu [I] num, stu [I]. Name, stu [I] sex, stu [I] college);
For (int j=0; J & lt; c; J++) {
Printf (" % 4 d, "stu [I] score [j]);
}
Printf (" % 7.2 f \ n ", stu [I] business);
}
return ;
}
Void the transform (struct students stu [], struct sexcode sexy [], struct collegecode colle [], int a, b int, int) c//modify information
{
for(int i=0; i For (int j=0; J & lt; b; J++) {
If (stu [I] sexnum==sexy [j]. J sexnum) {
Strcpy (stu [I]. Sex, sexy [j]. Journal of sex);
break;
}
}
For (int j=0; J & lt; c; J++) {
If (stu [I] collegenum==(colle [j]. J collegenum - 1)) {
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull