Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Design of C++ Simple Student Achievement Management System
Design of C++ Simple Student Achievement Management System
/* This program is applied to the string function atol to convert a string into a long integer value.

For example: cout

*/

# include & ltiostream & gt

# include & ltcstdlib & gt

# include & lt string & gt

# include & ltcstring & gt

usingnamespacestd

const int error = 0;

const int suc = 1;

classes

{

Private:

Stringname//string is a string class, in which a string of student names is defined.

Character number [11]; //Define char and prepare to call the character numeric conversion function atol.

floatsc _ computer

charmajor

Public:

stu();

Stu (string a, char b [], char c): name (a), sc _ computer(c)// constructor initialization.

{ int I = 0;

while(b[i]! = ' \ 0 '){ num[I]= b[I]; i++; }

num[I]= ' \ 0 '; }

int sort _ Sc(Stusc[],int count); //Sort students' information according to their computer scores.

int sub _ Major(Stu nm[],int count); //Learn by major.

int Show_Stu(Stu sc[],int count); //Display student information

int Init_Stu(Stu sc[],int count); //Student entry

};

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

intmain()

{

int CNT = 0;

Stu * Stu, Saint;

Char selection;

char ch 1;

Cout & lt& lt”\ t \ t * * * \ n \ n \ t \ Welcome to the student information management inquiry system \ n \ n \ t \ t * * \ n \ ";

Cout & lt& lt”\ t \ t \ t * * * * * * * * * menu * * * * * * * * * * * * * * * * * * * \ n \ ";

cout & lt& lt" \ t \ t \ t \ t 1 & gt; Student information entry \ n \ n ";;

Cout & lt& lt" \ t \ t \ t \ t2> Student information display \ n \ n ";;

Cout & lt& lt" \ t \ t \ t \ t3> student information sorting \ n \ n ";;

Cout & lt& lt" \ t \ t \ t \ t4> Student Major \ n "

Cout & lt& lt" \ t \ t \ t \ t0> exit \ n ";;

ch 1 = ' y ';

Do {

Cout & lt< "\ nPlease select a function option:";

CIN & gt; & gt selection;

Switch (selection)

{

Case "0": {ch1= "n"; Break; }

Case' 1':

Cout & lt& lt Please enter the number of students:

CIN & gt; & gtcnt

Stu = new Stu [CNT+1]; //Stu[0] does not store student information, starting with the array subscript 1.

st.Init_Stu(stu,CNT);

Break; }

Case' 2':

Cout & lt& lt "Output all student information:"

st.Show_Stu(stu,CNT);

Break; }

Case' 3':

st.Sort_Sc(stu,CNT);

st.Show_Stu(stu,CNT);

Break; }

Case' 4':

st.Sub_Major(stu,CNT);

st.Show_Stu(stu,CNT);

Break; }

Default value: {

Cout & lt& lt" \ a \ Warning: You entered it incorrectly. Do you want to enter again? (Yes/No) \ t ";;

CIN & gt; & gtch 1; } }

} while(ch 1 = = ' y ');

Returns 0;

}

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Stu::Stu(){ name = " 0 "; sc _ computer = 0; major =“0”; }

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Intstu:: sort _ sc (stusc [], int count)// Use bubble sorting method to operate.

{

if(count & lt; 1){

Cout & lt& lt "no student information"; Error returned; }

Otherwise {

for(int I = 1; I < count; i++)

for(int j = 1; j & lt= count-I; j++)

if(sc[j].sc _ computer & gtsc[j+ 1]。 Sc _ computer)

{ sc[0]= sc[j]; sc[j]= sc[j+ 1]; sc[j+ 1]= sc[0]; }

}

Return to suc

}

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int Stu::Sub _ Major(Stu nm[],int count)

{ long exg

if(count & lt; 1){

Cout & lt& lt "No student information"

Otherwise {

for(int I = 1; I < = count; i++)

{

if((exg=atol(nm[i])。 num))% 2 = = 0)nm[I]。 Major =' B// atlo is a function that converts a string into an integer.

Elson [me]. major = ' A

}

}

Return to suc

}

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Intstu:: show _ stu (stusc [], int count)// displays student information.

{

int I;

if(count & lt; 1){

Cout & lt& lt "No student information"

Otherwise {

Cout & lt& lt "student name \ t"

for(I = 1; I < = count; i++)

cout & lt& ltsc[i]。 Name & lt& lt" \ t \ t "<& ltsc[i]. num & lt& lt" \ t \ t " & lt& ltsc[i]。 Sc _ computer & lt& lt" \ t \ t "<& ltsc[i]. Major & lt& ltendl

}

returnsuc

}

Intstu:: init _ stu (stusc [], int count)// student input.

{ if(count & lt; 1){

Cout & lt& lt "No student information"

Otherwise {

Cout & lt& lt "student name \ t"

for(int I = 1; I < = count; i++)

CIN & gt; & gtsc[i]。 Name & gt& gtsc[i]. num & gt& gtsc[i]。 Sc _ computer;

}

Return to suc

}