Home > Back-end >  How will this problem according to the score to solve the problem of sorting?
How will this problem according to the score to solve the problem of sorting?

Time:10-06

#include
#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; exit(1);
}
//- student information input the corresponding number in turn -
for(i=0; i{
Cout<" When the name input is "0", stop input!!!!!! "& lt; Cout<" Please input your name: "& lt; Cin> Elegantly-named setname;
Name=elegantly-named setname;
If (elegantly-named setname=="0") break;
If (elegantly-named setname!="0")
{
N++;
Num++;
OutfileOutfileCout<" Please input the achievement of the c + + : "& lt; Cin> SetCscore;
Cscore=setCscore;
OutfileCout<" Please enter the gender: "& lt; Cin> Setsex;
Sex=setsex;
OutfileCout<" Please enter the political landscape: "& lt; Cin> Setpolitic;
Politic=setpolitic;
OutfileCout<" Please enter a home address: "& lt; Cin> Setaddress;
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; exit(1);
}
N=N + 1;
//- please input the corresponding data and appended to the file before -
Cout<" Please enter the data you want to add "& lt; Num++;
OutfileCout<" Please input your name: "& lt; Cin> Addname;
OutfileCout<" Please input the achievement of the c + + : "& lt; Cin> AddCscore;
Outfile<& lt; AddCscore<" ";
Cout<" Please enter the gender: "& lt; Cin> Addsex;
OutfileCout<" Please enter the political landscape: "& lt; Cin> Addpolitic;
OutfileCout<" Please enter a home address: "& lt; Cin> Addaddress;
OutfileOutfile. Close ();
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; exit(1);
}
for(i=0; i{
Cout<" ";
Infile> Num [I];
CoutInfile> The name [I];
CoutInfile> Cscore;
CoutInfile> Sex [I];
CoutInfile> Politic [I];
CoutInfile> Address [I];
Cout}
Cout<" Which one you want to delete?" Cin> k;
K=k - 1;
Infile. Close ();
Ofstream outfile (" student management system. TXT ", the ios: : out);
if(! Outfile)
{
Cerr<" Open the error "& lt; exit(1);//exit program
}
//- array access information output to a file -
for(i=0; i{
If (I.=k)
{
OutfileOutfileOutfileOutfileOutfileOutfile
  • Related