Home > Back-end >  Inquire of predecessors
Inquire of predecessors

Time:04-23

# include "string. H"
H # include "Windows."
# include "stdio.h"
# include "conio. H"
# define N 10
# define M 3
Struct student
{
int num;
Char name [15].
Int score [M];
float avg;
};
Int count;
Int sort_type=0;
Int n=1;
Struct student stu [N].
Void the quit ();
Void waiting ();
Void the sort ();
Void del ();
Void input ();
void display();
Void homepage ();
Void the modify ();
Void loadfile ();
Void newfile ();
Int main ()
{
Int I, k=0;
Char username [15], PWD [6].
Printf (" \ n \ n ");
Printf (" \ t# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# welcome the use of student management system # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# 2020.6.24 # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ n ");
for(i=0; i<3; I++)
{
Printf (" \ n please enter the user name: ");
Gets (username);
Printf (" \ n six please enter the password: ");
Gets (PWD).
If ((STRCMP (username, "Xty")==0) & amp; & (STRCMP (PWD, "777777")==0))
{
Printf (" \ n you have successfully login \ n ");
K=1;
for(i=0; i<20; I++)
{
Printf (". ");
Sleep (100);
}
System (" CLS ");
Homepage ();
break;
}
The else
Printf (" \ n the user name or password is invalid, please re-enter \ n ");
continue;
}
If (k==0)
Printf (" \ n input errors 3 consecutive will exit the program \ n ");
Sleep (2000);
The quit ();
return 0;
}
Void homepage ()
{
Char n;
Printf (" \ n \ n ");
Printf (" \ t# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# 1 shows result # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# 2. Input scores # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# 3. Delete records # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# 4. Order # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# 5. Modify the result # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# 0. Quit # \ n ");
Printf (" \ t# # \ n ");
Printf (" \ t# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # \ n ");
While ((n!='1') & amp; & (n!='2') & amp; & (n!='3') & amp; & (n!='4') & amp; & (n!='5') & amp; & (n!='6') & amp; & (n!='0'))
{
Printf (" \ n please select: ");
The fflush (stdin);
The scanf (" % c ", & amp; N);
The switch (n)
{
Case '1' : the display ();
system("pause");
break;
Case '2' : if (countThe input ();
The else
{
Printf (" record is full \ n ");
Sleep (2000);
System (" CLS ");
Homepage ();
}
Case: '3' del ();
break;
Case '4' : sort ();
break;
Case '5' : the modify ();
break;
Case '6' : newfile ();
break;
Case '0' : the quit ();
break;
Default: printf (" \ n option error \ n ");
}
}
}
Void loadfile ()
{
The FILE * fp.
int i=0;
If (n!=1)
{
Printf (" \ n \ t have imported file. \ n \ t press any key to continue ");
}
If ((fp=fopen (" stu_data. TXT ", "rb"))==NULL)
{
Printf (" \ n \ t can't open file!" );
N=1;
}
While (fread (& amp; Stu [I], sizeof (struct student), 1, fp)==1)
i++;
n=i;
Printf (" \ n \ t import end, total import % d student data. \ n \ t press any key to continue ", I);
fclose(fp);
return;
}
Void newfile ()
{
Int sle.
The FILE * fp.
Printf (" file option \ n ");
Printf (" 1 - new file \ n ");
Printf (" 2 - import files \ n ");
Printf (" 0 - return \ n ");
Printf (" please enter: \ n ");
The scanf (" % d ", & amp; Sle);
The switch (sle)
{
Case 1:
If ((fp=fopen (" stu_data. TXT ", "wb +"))!=NULL) printf (" new success!" );
N=0;
System (" CLS ");
Homepage ();
Case 2:
Loadfile ();
System (" CLS ");
Homepage ();
Case 0:
System (" CLS ");
Homepage ();
Default:
Printf (" input error, please input again!" );
}
fclose(fp);
}
Void the display ()
{
int i,j;
Loadfile ();
System (" CLS ");
The switch (sort_type)
{
Case 0: printf (" \ t \ t unsorted \ n \ n ");
break;
Case 1: printf (" \ t \ t sort by student number: \ n \ n ");
break;
Case 2: printf (" sort by grade 1: t \ \ t \ n \ n ");
break;
Case 3: printf (" sort by grade 2: t \ \ t \ n \ n ");
break;
Case 4: printf (" \ t \ t according to the grade 3 sort: \ n \ n ");
break;
Case 5: printf (" \ t \ t sort by grade point average: \ n \ n ");
}
Printf (" \ t student id name \ \ t t result 1 \ t grade 2 \ t result average 3 \ t \ n ");
for(i=0; i{
Printf (" \ \ t t % d % s ", stu [I] num, stu [I] name);
for(j=0; JPrintf (" \ t % 3 d, "stu [I] score [j]);
Printf (" \ t % 5.2 f \ n ", stu [I]. Avg);
}
system("pause");
System (" CLS ");
Homepage ();
}
Void input ()
{
Int I, numcheck;
float s;
char c;
Loadfile ();
System (" CLS ");
Do
{
Printf (" student id: \ n ");
The scanf (" % d ", & amp; Stu [count] num);
Numcheck=1;
If (stu) [r]. Count num<0)
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related