#include
#include
#include
#include
using namespace std;
# define total M/200/can save information
Const char Name [16]="administrator".//define internal user name
Const char P [16]="123456789";//define internal password
Int N=0;//total student
The class student
{
Public:
Student (a);
Void the set ();//initialize the information, the first entry of information
Void the add ();//to add student information
Void del ();//delete a student information
Void change ();//modify a student information
Void the search ();//query a student information
Void the display ();//show all student information
Void scoreturn ();//in accordance with the scores of students in reorder
Private:
Static int num.
String name, sex, politic, address;
Int Cscore;
};
Int student: : num=130500;
Student: : student () {}
///the initialization file
Student stu.
Void StuSystem ()
{
Char ch;
Void menu ();
menu();
Cin> Ch;
While (ch!='0')
{
System (" CLS ");
The switch (ch)
{
Case '1' : stu. The set (); break;
Case '2' : stu. The add (); break;
Case '3' : stu. Del (); break;
Case '4' : stu. Change (); break;
Case '5' : stu. The search (); break;
Case '6' : stu. The display (); break;
Case '7' : stu scoreturn (); break;
Case '0' : cout<" Log out!" ; break;
Default: cout<" There is no this option!"
menu();
Cin> Ch;
}
}//main program code encapsulation, and then use the packaging bag, the preparation of the user login function
Void student: : set ()
{
int i;
String elegantly-named setname, setsex setpolitic setaddress;
Int setCscore;
//int studentscore;
Ofstream outfile;
Outfile. Open (" student management system. TXT ", the ios: : out);//- open the file -
if(! Outfile)
{
Cerr<" Open the error "& lt;
}
//- student information input the corresponding number in turn -
for(i=0; i
Cout<" When the name input is "0", stop input!!!!!! "& lt;
Name=elegantly-named setname;
If (elegantly-named setname=="0") break;
If (elegantly-named setname!="0")
{
N++;
Num++;
Outfile
Cscore=setCscore;
Outfile
Sex=setsex;
Outfile
Politic=setpolitic;
Outfile
Address=setaddress;
Outfile
}
Outfile. Close ();//- close the file -
}
///add files
Void student: : add ()
{
String addname, addsex addpolitic addaddress;
Int addCscore;
//- in the form of additional input information, directly to the information appended to the end of the file before -
Ofstream outfile (" student management system. TXT ", the ios: : app);
if(! Outfile)
{
Cerr<" Open the error "& lt;
}
N=N + 1;
//- please input the corresponding data and appended to the file before -
Cout<" Please enter the data you want to add "& lt;
Outfile
Outfile
Outfile<& lt; AddCscore<" ";
Cout<" Please enter the gender: "& lt;
Outfile
Outfile
Outfile
Cout<" Has been added successfully!"
///delete files
Void student: : del ()
{
Int k, I;
Int num [M];
String name [M], sex [M], politic [M], address [M].
Int Cscore;
Ifstream infile (" student management system. TXT ", the ios: : in);
if(! Infile)
{
Cerr<" Open the error "& lt;
}
for(i=0; i
Cout<" ";
Infile> Num [I];
Cout
Cout
Cout
Cout
Cout
Cout
Cout<" Which one you want to delete?"
K=k - 1;
Infile. Close ();
Ofstream outfile (" student management system. TXT ", the ios: : out);
if(! Outfile)
{
Cerr<" Open the error "& lt;
}
//- array access information output to a file -
for(i=0; i
If (I.=k)
{
Outfile