Home >
Back-end > Small white made a student information management system, but do not know why wrong interface is to
Small white made a student information management system, but do not know why wrong interface is to
/* the students' basic information includes the following fields: student id, name, class, physical four classes of Chinese maths English achievement
Basic management information system for students, including student information to add, delete, change, check, statistics, storage, and other functions, specific functional requirements are as follows:
1, increase students' information, prompt the user for the new student information, information can be imported in succession more students,
2, delete student information, prompt the user for student id to be deleted, if the student information, will be the student number corresponds to delete student information, otherwise the output message,
3, modify the students information, prompt the user input to modify student number, if the student information exists, will prompt the user for the modified data, otherwise the output message,
4, query student information, according to different conditions on the student information query operation, output meet the conditions of students information,
5, basic statistics, basic statistical analysis was carried out on the student information,
6, student information preservation, according to the result of all information related to the student after the operation, the relevant student information stored in the file, */
# include & lt; Stdio. H>
# include & lt; String. H>
# include & lt; The malloc. H>
Struct stud
{
int num;
Char name [30].
Char classnum;
Int score [4];
Struct stud * next;
};
Struct stud * head=NULL;
Void InsertStud ()
{
Char s [10];
Do
{
Int TMP.
Printf (" please enter the student id: \ n ");
The scanf (" % d ", & amp; TMP);
Struct stud * q, * p;
P=the head;
While (p!=NULL)
{
If (p - & gt; Classnum==TMP)
{
Printf (" the student already exists! \n");
return;
}
P=p - & gt; Next;
}
Q=(struct stud *) malloc (sizeof (struct stud));
If (q==NULL)
{
Printf (" \ n application memory failure ");
return;
}
Q - & gt; Classnum=TMP;
Printf (" please input your name: ");
The scanf (" % s ", q - & gt; Name);
Printf (" please enter the student id: ");
The scanf (" % d ", & amp; Q - & gt; Num);
Printf (" please enter the class: ");
The scanf (" % s ", & amp; Q - & gt; Classnum);
Printf (" please enter the four classes of grade: ");
The scanf (" % d % d % d % d ", & amp; Q - & gt; Score [0], & amp; Q - & gt; Score [1], & amp; Q - & gt; Score [2], & amp; Q - & gt; Score [3]);
Q - & gt; Next=NULL;
P=the head;
If (p==NULL)
{
The head=q;
}
The else
{
While (p - & gt; Next!=NULL)
{
P=p - & gt; Next;
}
P - & gt; Next=q;
}
Printf (" students increase success! \n");
Printf (" do you still need to continue to input student information? (no exit) : ");
The scanf (" % s ", s);
}
While (STRCMP (strupr (s), and "NO").=0);
}
Void DelStud ()
{
Int flag=1;
int num;
Printf (" please enter to delete student student id: \ n ");
The scanf (" % d ", & amp; Num);
Struct stud * p, * q;
P=q=head;
While (p!=NULL& & Flag==1)
{
If (p - & gt; Classnum==num)
{
If (p==head)//remove the first node
{
The head=p - & gt; Next;
Free (p);
}
The else
{
Q - & gt; Next=p - & gt; Next;
Free (p);
}
Flag=0;
Printf (" delete student information successfully! \n");
return;
}
The else
{
q=p;
P=p - & gt; Next;
}
}
If (flag==1)
{
Printf (" could not find can delete student student id! \n");
}
}
Void UpdateStud ()
{
Int flag=1;
int num;
Printf (" please input to modify the student's student id: \ n ");
The scanf (" % d ", & amp; Num);
Struct stud * p;
P=the head;
While (p!=NULL& & Flag==1)
{
If (p - & gt; Num==num)
{
Printf (" please enter the new student id: \ n ");
The scanf (" % d ", & amp; P - & gt; Num);
Printf (" please enter a new name: \ n ");
The scanf (" % s ", p - & gt; Name);
Printf (" please enter a new class: \ n ");
The scanf (" % s ", p - & gt; Classnum);
Printf (" please enter a new achievement: \ n ");
The scanf (" % d % d % d % d ", & amp; P - & gt; Score [0], & amp; P - & gt; Score [1], & amp; P - & gt; Score [2], & amp; P - & gt; Score [3]);
Flag=0;
Printf (" student information modify operation success \ n ");
}
The else
{
P=p - & gt; Next;
}
}
If (flag==1)
{
Printf (" not found to modify records \ n ");
}
}
Void QueryStud ()
{
Int flag=1;
int num;
Struct stud * p;
Printf (" please enter student id to query: \ n ");
The scanf (" % d ", & amp; Num);
P=the head;
While (p!=NULL& & Flag==1)
{
If (p - & gt; Num==num)
{
Name: printf (" % s ", p - & gt; Name);
Printf (" student id: % d ", & amp; P - & gt; Num);
Class: printf (" % s ", p - & gt; Classnum);
Printf (" math language result: % d: % d English: physical achievement: % d % d ", & amp; P - & gt; Score [0], & amp; P - & gt; Score [1], & amp; P - & gt; Score [2], & amp; P - & gt; Score [3]);
Flag=0;
}
The else
{
P=p - & gt; Next;
}
}
If (flag==1)
{
Printf (" no query to query information!" );
}
}
/* void StaticStud ()
{
}
*/
Void SaveStud ()
{
The FILE * fp.
If ((fp=fopen (" stud. Dat ", "wb"))==NULL);//open file stud. Dat
{
Printf (" file open failed \ n ");
return;//open the exit failure
}
Struct stud * p;
P=the head;
While (p!=NULL)
{
Fwrite (p, sizeof (struct stud), 1, fp);
P=p - & gt; Next;
}
The fclose (fp);//close the file
Printf (" student information saved successfully! \n");
}
Int fileexist (char * filename)
{
The FILE * fp.
If ((fp=fopen (filename, "rb"))==NULL)
return 0;
The else
{
The fclose (fp);
return 1;
}
}
Void the load ()
{
If (fileexist (" stud. Dat ")==0)
return;
The FILE * fp.
If ((fp=fopen (" stud. Dat ", "rb"))==NULL)
{
Printf (" file open failed! \n");
return;
}
Struct stud * p, * q;
P=the head;
while(! The feof (fp))
{
Q=(struct stud *) malloc (sizeof (struct stud));
If (q==NULL)
{
Printf (" application memory failed! \n");
return;
}
Fread (q, sizeof (struct stud), 1, fp);
Q - & gt; Next=NULL;
If (p==NULL)
{
The head=p;
}
The else
{
While (p - & gt; Next!=NULL)
{
P=p - & gt; Next;
}
P - & gt; Next=q;
}
}
The fclose (fp);
}
Int main ()
{
int i;
Load ();
Do
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull