课程设计报告--学生成绩管理系统(附源代码) 2 联系客服

发布时间 : 星期二 文章课程设计报告--学生成绩管理系统(附源代码) 2更新完毕开始阅读8fb2c1af770bf78a652954ef

六、附件

程序源代码清单: #include #include #include #include using namespace std; class student {

private: string number; string name; double computer; double English; double math; double sum; double ave; char grade; student *head; student *curnode;

student *next;

public: student();//不带参数的构造函数

student(string ,string ,double ,double ,double ,double =0.0,double =0.0,char =NULL);带数据域参数的构造函数,用来动态建立节点 void sum_score();//总分函数 void ave_score();//平均分函数 void grade_score();//成绩等级

void cin_app();//修改用

void app_score(string ,string ,double ,double ,double); //动态的建立节点 void del_score(); //删除全部节点

void displist(); //输出节点中的全部数据 void lookup(int ,string ); //查找函数

void del_score(int ,string ); //删除函数 void compositor(int ,int ); //排序函数 void rework(int ,string ); //修改函数

};

/////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////student类的实现 void err_char();//输入错误字符检测函数

12

//

void score_err();//成绩范围检测函数,当输入成绩不在0到100之间时提示重新输入 student::student():next(NULL)//不带参数的构造函数 { head=curnode=this; }

//带参数的构造函数 student::student(string

Number,string

Name,double

Computer,double

ENglish,double

Math,double Sum,double Ave,char Grade):next(NULL) {

number=Number; name=Name;

computer=Computer; English=ENglish; math=Math; sum=Sum; ave=Ave;

grade=Grade; }

void student::sum_score()///////////////////////计算总成绩 {sum=computer+English+math;}

void student::ave_score()/////////////////////计算平均成绩 {ave=(computer+English+math)/3.0;}

void student::grade_score()///////////////////计算成绩等级 { }

void student::app_score(string Number,string Name,double Computer,double ENglish,double Math)//动态建立节点 { }

int i; i=ave;

switch(i/10) { case 10: grade='A'; break; }

case 9: grade='A'; break; case 8: grade='B'; break; case 7: grade='C'; break; case 6: grade='D'; break; default: grade='E';

curnode->next=new student(Number,Name,Computer,ENglish,Math); curnode=curnode->next;

13

void student::del_score()//////////////////////删除表中的全部数据 {

student *p;

curnode=head->next; while(curnode!=NULL) {

p=curnode->next; delete curnode; curnode=p;

}

head->next=NULL;

curnode=head; cout<<\┏━━━━━━━━━━━━━━━━━━━┓\cout<<\┃ !表中内容全部清空,现已是一个空表! ┃\cout<<\┗━━━━━━━━━━━━━━━━━━━┛\

cout<<\}

void student::displist()////////////////////////输出表中的全部数据 {

if(head->next==NULL) { cout<<\┏━━━━━━━━━┓\ cout<<\┃ !这是一个空表! ┃\

cout<<\┗━━━━━━━━━┛\cout<<\

return; }

student *pw=curnode;

curnode=head->next; cout<<\┏━━━━━┳━━━━━┳━━━┳━━━┳━━━┳━━━━┳━━━━┳━━┓\ cout<<\┃ 学号 ┃ 姓名 ┃计算机┃ 英语 ┃ 数学 ┃ 总分 ┃ 平均分 ┃等级┃\

cout<<\┣━━━━━╋━━━━━╋━━━╋━━━╋━━━╋━━━━╋━━━━╋━━┫\while(curnode!=NULL) {

cout<<\┃\cout<<\┃\cout<<\┃\cout<<\┃\cout<<\┃\curnode->sum_score(); cout<<\┃\

14

curnode->ave_score();

cout<<\┃\curnode->grade_score(); cout<<\┃\┃\if(curnode->next!=NULL)

cout<<\┣━━━━━╋━━━━━╋━━━╋━━━╋━━━╋━━━━╋━━━━╋━━┫\ }

else

cout<<\┗━━━━━┻━━━━━┻━━━┻━━━┻━━━┻━━━━┻━━━━┻━━┛\

curnode=curnode->next;

curnode=pw; cout<<\┏━━━━━━━━━┓\cout<<\┃!表中内容输出完毕!┃\cout<<\┗━━━━━━━━━┛\

cout<<\}

////////////////////////////////////////输入数据 void student::cin_app() {

student *p=curnode; bool b=0;

string Number; string Name;

double Computer; double ENglish; double Math; while(1) {

cout<<\学 号:\cin>>Number;

curnode=head->next; while(curnode!=NULL) { }

b=(Number==curnode->number); curnode=curnode->next;

if(!b)

break;

else { cout<<\┏━━━━━━━━━━━━━━┓\

15