#include
#include
#include
# define M 100
Int count=0;
Struct student
{
Char name [25];
Int num [25];
Int grades;
} stu [M];
Void Choice ()
{
Int a=0;
The scanf (" % d ", & amp; A);
The switch (a)
{
Case 0: printf (" exit successfully \ n "); break;
Case 1: printf (" * * 1. Input information \ n "); The Input (); break;
Case 2: printf (" * * 2. Save the information \ n "); Save (); break;
Case 3: printf (" * * 3. The query information \ n "); Search (). break;
Case 4: printf (" * * 4. Browse information \ n "); The Output (); break;
Case 5: printf (" * * 5. Modify the information \ n "); Amend (); break;
Case 6: printf (" * * 6. Delete information \ n "); The Delete (); break;
Case 7: printf (" * * 7. Read the information \ n "); Read (); break;
}
}
Void the Read ()
{
Int a=0;
Char b;
FILE *fp;
system("cls");
Printf (" please make sure the information entered or entities students: 'Y' or 'N' \ N ");
The scanf (" % c, & amp; B ");
The fflush (stdin);
While (b! & amp;='Y' & b!='N')
{
Printf (" input error, please make sure the information entered or entities students: 'Y' or 'N' \ N ");
The scanf (" % c ", & amp; B);
The fflush (stdin);
}
If ((fp=fopen (" D: \ student achievement record sheet ", "rb"))==NULL)
{printf (" file open error, please revisit the path 'D: \ student achievement records' whether there is a thin!" );
exit(0); }
Fread (& amp; Stu [a], sizeof (struct student), 1, fp);
count=0;
count++;
a++;
While (fread (& amp; Stu [a], sizeof (struct student), 1, fp))
{
a++;
The count.
}
fclose(fp);
Printf (" at the end of data read \ n ");
system("cls");
The Menu ();
Choice ();
return 0;
}
Void the Save ()
{
Int a=0; Char b; FILE *fp;
Printf (" confirm student information input to complete! Y or N \ N ");
The scanf (" % c ", & amp; B);
The fflush (stdin);
While (b! & amp;='Y' & b!='N')
{
If (b! & amp;='Y' & b!='N')
Printf (" input error, to re-enter \ n ");
Printf (" confirmation please enter Y, return to the main menu click N! \n");
The scanf (" % c ", & amp; B);
The fflush (stdin);
If (b=='Y')
{
If ((fp=fopen (" D: \ student achievement record sheet ", "wb"))==NULL)
{
Printf (" file open error, please check again the path 'D: \ student achievement records' whether there is a thin!" );
exit(0);
}
for(a=0; a
Fwrite (& amp; Stu [a], sizeof (struct student), 1, fp);
}
fclose(fp);
If (count==0)
Printf (" not to save the data, please confirm your student information \ n ");
The else
Printf (" data is saved! \n");
}
The else
system("cls");
The Menu ();
Choice ();
return 0;
}
}
Void Input ()
{
int len;
system("cls");
Printf (" please enter the student information \ n ");
Do
{printf (" please enter the student student number (12 digits) \ n ");
The scanf (" % s ", & amp; Stu [count] num);
Len=strlen (stu) [r]. Count num);
}
While (len!=12);
Printf (" input the student's name (pinyin) \ n ");
The scanf (" % s ", stu [count] name);
Do {
Printf (" please enter the student achievement \ n ");
The scanf (" % d ", & amp; Stu [r]. Count grades);
}
While (stu) [r]. Count grades> 100);
count++;
system("pause");
system("cls");
The Menu ();
Choice ();
return 0;
}
Void the Output ()
{
int j;
system("cls");
If (count==0)
{
Printf (" there is no information in the program \ n ");
return;
}
for(j=0; j
for(j=0; j
Student id: printf (" % s ", stu [j]. Journal of num);
Name: printf (" % s ", stu [j]. Name);
Printf (" grade: % d ", stu [j]. Journal of grades);
}
}
}
Void the Delete ()
{
Int nm;
system("cls");
If (count==0)
{
Printf (" database is empty! \n");
return;
}
The else
{
Printf (" input 1 student id can be deleted information, enter 2 can delete information by name, enter 3 exit, \ n ");
The scanf (" % d ", & amp; Nm);
The switch (nm)
{
Case 3: return; break;
Case 1: Deletebynum (); break;
Case 2: Deletebyname (); break;
}
}
}
Void Amend ()
{
Int j, coure;
Char ch [25];
system("cls");
If (count==0)
{
Printf (" no information in database! \n");
return;
}
The else
{
Printf (" please input to modify student student id \ n ");
The scanf (" % s ", & amp; Ch);
The fflush (stdin);
for(j=0; j
{
Printf (" ");
}
}
}
Void the Search ()
{
Int KB;
system("cls");
If (count==0)
{
Printf (" the current database is empty! \n");
return;
}
The else
{
Printf (" please enter 1 for by name lookup or input 2 by student number lookup \ n ");
The scanf (" % d ", & amp; KB);
The switch (KB)
{
Case 1: printf (" by name (pinyin) find... \n"); Byname (); break;
Case 2: printf (" according to the student id to find... \n"); Bynum (); break;
Default: printf (" input error \ n ");
}
}
}
Void Byname ()
{
int j=0;
Char cx [25];
Printf (" please input you want to find the student's name (pinyin) \ n ");
The scanf (" % s ", & amp; Cx);
The fflush (stdin);
for(j=0; j
If (STRCMP (stu [j]. Name, cx)==0)
{
Student id: printf (" % s ", stu [j]. Journal of num);
Name: printf (" % s ", stu [j]. Name);
Printf (" grade: % d ", stu [j]. Journal of grades);
If (j==count)
{
Printf (" information without the students \ n ");
return;
}
}
}
}
Void Bynum ()
{
int j=0;
Char ch [25];
Printf (" please enter your student id to find students (12 digits) \ n ");
The scanf (" % s ", & amp; Ch);
The fflush (stdin);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
