Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Using C++ to Write Student Achievement Management System
Using C++ to Write Student Achievement Management System
I wrote it before. Purpose: Students' grade management, each student includes three grades. Input student information from the keyboard, including student number, name and scores of three courses. Calculate the average score of the college, and arrange it according to the average score from big to small.

In addition, the function of (1) insertion is realized, and the grade ranking is required to be maintained after insertion. .

(2) Delete function to enter the specified student number. Delete from the student information table, and the deleted grades will keep the original order!

// -

# contains "stdafx.h"

# include & ltWindows.h & gt

# include & ltvector & gt

# include & lt string & gt

# include & ltiostream & gt

# include & lt algorithm & gt

Use STD:: CIN;

Use STD:: cout;

Class management students

{

Public:

BOOL InputOneStudent();

BOOL DelOneStudent();

void showall student();

Private:

void sort data();

structural information

{

Std:: string name; //Name

INT iStudentID// student number

INT iles son 1; //result

INT iLesson2

INT iLesson3

International travel; //Average score

Info(){}

Information (INT iID)

:iStudentID(iID)

{

}

//judging equality is used for find_if ()

Boolean operator () (constant information & data) constant

{

Return this-> iStudentID = = data.iStudentID

}

//The equality judgment is used to sort sort sort () from the largest to the smallest.

Boolean operator () (constant information & amp data 1, constant information and. Data 2) Constant

{

Return data1.i verage > data 2 . I verage;

}

} oneInfo

STD::vector & lt; Info & gtvStudent

};

BOOL cmanagementstudent::inputone student()

{

Cout & lt& lt "Please enter your student number, and cancel entering-1\ n";

CIN & gt; & gtoneInfo.iStudentID

if(oneinfo . istudentid = =- 1)

Returns FALSE

if ( find_if( vStudent.begin()、vStudent.end()、oneInfo)! = vStudent.end())

{

Cout & lt& lt "student number already exists! \ n ";

Returns FALSE

}

Cout & lt& lt "Please enter a name and cancel to exit \ n";

CIN & gt; & gtoneInfo.name

if (oneInfo.name == "exit ")

Returns FALSE

Cout & lt& lt "Please enter the score of 1 course, and quit entering-1\ n";

CIN & gt; & gtoneinfo . ilesson 1;

if(oneinfo . ilesson 1 = =- 1)

Returns FALSE

Cout & lt& lt "Please enter the score of the second course, and quit entering-1\ n";

CIN & gt; & gtoneinfo . iles son 2;

if (oneInfo.iLesson2 == - 1)

Returns FALSE

Cout & lt& lt "Please enter the score of the third course, and quit entering-1\ n";

CIN & gt; & gtoneinfo . iles son 3;

if (oneInfo.iLesson3 == - 1)

Returns FALSE

oneinfo . I verage =(oneinfo . iles son 1+oneinfo . iles son 2+oneinfo . iles son 3)/3;

vstudent . push _ back(oneInfo);

sort data(); //After inserting a piece of data, it needs to be sorted, but it cannot be deleted.

Return TRUE

}

void cmanagementstudent::sort data()

{

sort(vStudent.begin()、vStudent.end()、cmanagementstudent::Info());

}

void cmanagementstudent::showall student()

{

for(STD::vector & lt; Info & gt* iterator it = vstudent.begin (); vStudent.end()! = it++it)

{

Cout & lt& lt "Student name:"

& lt& lt "Student ID:"

& lt& lt "China's achievements:"

& lt& lt "Math scores:"

& lt& lt "English score:" << it-> iLesson3

& lt& lt "Average grade:"

& lt& ltSTD::endl;

}

}

BOOL CManageStudent::DelOneStudent()

{

Cout & lt& lt "Please enter your student number, and cancel entering-1\ n";

CIN & gt; & gtoneInfo.iStudentID

if(oneinfo . istudentid = =- 1)

Returns FALSE

STD::vector & lt; Info & gt* iterator it = find_if( vStudent.begin (), vStudent.end (), oneinfo);

if ( it == vStudent.end())

{

Cout & lt& lt "Student number does not exist!" ;

Returns FALSE

}

vstudent . erase(it);

Return TRUE

}

void main()

{

int stop = 0;

cmanagementstudent rMS;

While (true)

{

Cout & lt& lt "Exit input 0\n"

& lt& lt "Enter new information and enter 1\n"

& lt& lt "Delete information input 2\n"

< < "display information input 3 \ n";

CIN & gt; & gt stop;

Switch (stop)

{

Case 0:

Return;

Case 1:

rMS。 inputone student();

Break;

Case 2:

rMS。 DelOneStudent();

Break;

Case 3:

rMS。 showall student();

Break;

Default value:

Break;

}

}

}

STL is made of standard c++ template library, and its content is still very useful. It should be better to add a function to display all the information ~