数据结构课程设计成绩管理系统.docx
- 文档编号:7169892
- 上传时间:2023-01-21
- 格式:DOCX
- 页数:17
- 大小:18.29KB
数据结构课程设计成绩管理系统.docx
《数据结构课程设计成绩管理系统.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计成绩管理系统.docx(17页珍藏版)》请在冰豆网上搜索。
数据结构课程设计成绩管理系统
数据结构课程设计
(1)学生成绩管理问题(建议数据结构:
单链表)
学生成绩管理是学校教务管理的重要组成部分,其处理信息量很大,本设计是对学生的成绩管理做一个简单的模拟,用菜单选择操作方式完成下列主要功能:
(1)登记学生成绩;
(2)查询学生成绩;
(3)插入学生成绩;
(4)删除学生成绩;
要求对每个功能分别用函数实现。
(2)学生成绩管理系统需求与功能分析
学生成绩的录入、统计、查询、修改、删除、输出。
画出功能结构图。
(3)学生成绩管理系统的数据结构表
序号成员名(字段名)数据类型长度字段含义
1class_0char20班级
2numint学号
3namechar8姓名
4elecflaot电子技术
5c_progfloatC程序设计
6mediaflaot多媒体技术
7engfloat大学英语
8mathfloat高等数学
9sportfloat大学体育
10polityfloat马克思主义政治经济学
11avefloat平均成绩
12orderint名次
(4)学生成绩管理系统测试数据表
class_0numnameelecc_progmediaengmathsportpolityaveorder
网络303313033101办公费80706070706080表中其余数据自己编造。
(5)使用链表编写程序(手写源程序代码,并给出注解)
0)定义链表结点
1)主函数main():
定义链表头指针,调用录入、统计等函数对成绩表进行处理;
2)建立链表函数Create():
输入班级到政治课成绩信息;
3)统计函数Statistic():
计算平均成绩;
4)查询函数Lookup():
查询指定学号学生成绩记录;
5)修改函数Modify():
修改指定学号学生成绩记录;
6)删除函数删除():
删除指定学号学生记录;
7)输出函数Output():
输出班级所有学生成绩记录;
8)插入函数Insert():
按平均分顺序插入新结点。
9)排序函数Sort():
按平均分对学生成绩记录项进行降序排序;
程序如下:
#include
#include
#include
#include
#include
usingnamespacestd;
structNode//定义链表结点
{
char*class_0;//班级
intnumber;
char*name;//姓名
floatelec;//电子技术成绩
floatc_prog;//C程序设计成绩
floatmedia;//多媒体技术成绩
floateng;//大学英语成绩
floatmath;//高等数学成绩
floatsport;//大学体育成绩
floatpolity;//马克思主义政治经济学成绩
floatave;//平均成绩
intorder;//名次
Node*link;
Node(){link=NULL;}
Node(int_number,char*_class_0,char*_name,float_elec,
float_c_prog,float_media,float_eng,float_math,
float_sport,float_polity,float_ave,int_order,Node*next)
{
number=_number;
class_0=newchar[21];
strcpy(class_0,_class_0);
name=newchar[9];
strcpy(name,_name);
elec=_elec;
c_prog=_c_prog;
media=_media;
eng=_eng;
math=_math;
sport=_sport;
polity=_polity;
ave=_ave;
order=_order;
link=next;
}
~Node()
{
删除[]class_0;
删除[]name;
}
};
classStudentScore
{
private:
Node*first;//链表的头指针
intchoice;//选择数据的读入方式
intfileNum;//当前文件数减一
intfileLoc;//定位当前文件
string*fileName;
intoperChoice;
intRecordLength;
public:
StudentScore();
voidSave();
voidBuildList();//手工建立成绩链表
voidReadInfo(intk);//从内存中读入学生信息
voidClearList();
voidStatistic();
voidSort();
voidAdd();
void删除();
voidPrintList();
voidMenu();
};
StudentScore:
:
StudentScore()
{
RecordLength=0;
operChoice=0;
first=NULL;
choice=0;
fileLoc=0;
fileNum=0;
fileName=newstring[10];//最多可以存10个文件
}
intGetOrder(Node*first,floatave);
voidStudentScore:
:
BuildList()
{
int_number;//学号
char*_class_0=newchar[21];//班级
char*_name=newchar[9];//姓名
float_elec;//电子技术成绩
float_c_prog;//C程序设计成绩
float_media;//多媒体技术成绩
float_eng;//大学英语成绩
float_math;//高等数学成绩
float_sport;//大学体育成绩
float_polity;//马克思主义政治经济学成绩
float_ave;//平均成绩
int_order;//名次
charc;
Node*p,*r=NULL;
first=NULL;
cout<<"您要输入学生成绩信息?
" while(tolower(c)! ='n') { cin>>_class_0;//班级 cin>>_number; cin>>_name;//姓名 cin>>_elec; cin>>_c_prog; cin>>_media; cin>>_eng; cin>>_math; cin>>_sport; cin>>_polity; _ave=(_elec+_c_prog+_media+_eng+_math+_sport+_polity)/7;//求得平均成绩 _order=GetOrder(first,_ave); p=newNode(_number,_class_0,_name,_elec, _c_prog,_media,_eng,_math,_sport,_polity, _ave,_order,NULL);//建立一个新的结点储存信息 if(first! =NULL) r->link=p; elsefirst=p; r=p; RecordLength++; cout<<"您要输入学生成绩信息? " } } intGetOrder(Node*first,floatave)//名次记录有严重问题 { intorder=1; Node*temp=first; for(;temp;temp=temp->link) {if(temp->ave>ave)order++; if(temp->aveorder)++; } returnorder; } voidStudentScore: : Statistic() { Node*temp=first; floata_elec=0.0;//电子技术成绩 floata_c_prog=0.0;//C程序设计成绩 floata_media=0.0;//多媒体技术成绩 floata_eng=0.0;//大学英语成绩 floata_math=0.0;//高等数学成绩 floata_sport=0.0;//大学体育成绩 floata_polity=0.0;//马克思主义政治经济学成绩 inti=0; while(temp) { a_elec+=temp->elec; a_c_prog+=temp->c_prog; a_media+=temp->media; a_eng+=temp->eng; a_math+=temp->math; a_sport+=temp->sport; a_polity+=temp->polity; i++; temp=temp->link; } a_elec=a_elec/i; a_c_prog=a_c_prog/i; a_media=a_media/i; a_eng=a_eng/i; a_math=a_math/i; a_sport=a_sport/i; a_polity=a_polity/i; cout<<"电子技术平均成绩为: " " " " " " "<} voidStudentScore: : 删除() { intstudNum; Node*p; Node*temp=first; cout<<"请输入要删除的学生学号" floataverage; for(;temp;temp=temp->link) { cout if(temp->number==studNum) { average=temp->ave; if(temp==first)//说明是第一次 { first=first->link; 删除temp; break;//如果不跳出的话temp=temp->link会出错 } else { p->link=temp->link; 删除temp; break; } } p=temp; RecordLength--; } //下面修改学生排名 temp=first; for(;temp;temp=temp->link) if(temp->aveorder--; } voidStudentScore: : Add() { int_number;//学号 char*_class_0=newchar[21];//班级 char*_name=newchar[9];//姓名 float_elec;//电子技术成绩 float_c_prog;//C程序设计成绩 float_media;//多媒体技术成绩 float_eng;//大学英语成绩 float_math;//高等数学成绩 float_sport;//大学体育成绩 float_polity;//马克思主义政治经济学成绩 float_ave;//平均成绩 int_order;//名次 charc; Node*p,*r=NULL; r=first; while(r->link) r=r->link; //first=NULL; cout<<"您要输入学生成绩信息? " while(tolower(c)! ='n') { cin>>_class_0;//班级 cin>>_number; cin>>_name;//姓名 cin>>_elec; cin>>_c_prog; cin>>_media; cin>>_eng; cin>>_math; cin>>_sport; cin>>_polity; _ave=(_elec+_c_prog+_media+_eng+_math+_sport+_polity)/7;//求得平均成绩 //写一个返回排名的程序 _order=GetOrder(first,_ave); p=newNode(_number,_class_0,_name,_elec, _c_prog,_media,_eng,_math,_sport,_polity, _ave,_order,NULL);//建立一个新的结点储存信息 if(first! =NULL) r->link=p; elsefirst=p; r=p; RecordLength++; cout<<"您要输入学生成绩信息? " } } voidStudentScore: : Sort()//简单bubble排序从高分到低分排序 { inti=0; Node*temp=first; Node*before; //Node*p=first; for(;temp->link;) { if(temp->avelink->ave) { if(temp==first)//说明是第一个结点 { first=first->link; //p=temp; //temp=temp->link; temp->link=temp->link->link; first->link=temp; before=first; } else//不是第一个结点 { before->link=temp->link; temp->link=temp->link->link; before->link->link=temp; before=before->link; } } else { temp=temp->link; } i++;//计算次数 } for(;i>0;i--) { temp=first; for(intj=0;j{ if(temp->avelink->ave) { cout<<"small! " { first=first->link; //p=temp; //temp=temp->link; temp->link=temp->link->link; first->link=temp; before=first; } else//不是第一个结点 { before->link=temp->link; temp->link=temp->link->link; before->link->link=temp; before=before->link; } } else { temp=temp->link; } } } } /* boolIsSorted(Node*first) { for(;first;first=first->link) if(first->avelink->ave)returnfalse; returntrue; }*/ voidStudentScore: : PrintList()//打印链表程序 { cout<<"Thelistcontains: " for(;temp;temp=temp->link) { cout } voidStudentScore: : ClearList()//清除链表 { Node*p=newNode; while(first) { p=first->link; 删除first; first=p; } } //读函数 voidStudentScore: : ReadInfo(intk)//读第k个文件的信息存入链表 { //intwordLength;//记录子段长度 int_number;//学号 char*_class_0=newchar[21];//班级 char*_name=newchar[9];//姓名 float_elec;//电子技术成绩 float_c_prog;//C程序设计成绩 float_media;//多媒体技术成绩 float_eng;//大学英语成绩 float_math;//高等数学成绩 float_sport;//大学体育成绩 float_polity;//马克思主义政治经济学成绩 float_ave;//平均成绩 int_order;//名次 Node*p,*r=NULL; first=NULL; ifstreamInfile(fileName[k].c_str()); if(! Infile) { cout<<"fileisnotpresent! " } Infile>>RecordLength; cout Infile>>_class_0;//班级 //cout<<_class_0; Infile>>_number; Infile>>_name;//姓名 Infile>>_elec; Infile>>_c_prog; Infile>>_media; Infile>>_eng; Infile>>_math; Infile>>_sport; Infile>>_polity; Infile>>_ave; Infile>>_order; _ave=(_elec+_c_prog+_media+_eng+_math+_sport+_polity)/7;//求得平均成绩 //写一个返回排名的程序 _order=GetOrder(first,_ave); p=newNode(_number,_class_0,_name,_elec, _c_prog,_media,_eng,_math,_sport,_polity, _ave,_order,NULL);//建立一个新的结点储存信息 if(first! =NULL) r->link=p; elsefirst=p; r=p; } } voidStudentScore: : Save() { stringtempName; cout<<"请输入将要保存的文件名: "/要判断是否跟现有文件重名 cin>>tempName; ofstreamsavefile(tempName.c_str());//要做一个转换 Node*temp=first; savefile { savefile savefile.close(); //读取文件表信息 ifstreamReadfileinfo("FileRecord.txt"); Readfileinfo>>fileNum; for(inti=0;iReadfileinfo>>fileName[i]; Readfileinfo.close(); fileNum++; fileName[i]=tempName; //修改文件表信息 ofstreamchangefile("FileRecord.txt"); changefile } voidStudentScore: : Menu() { cout<<"请您选择数据的读入方式: " (1)重新手动建立一份新的数据表" (2)从文件中读入数据" "; cin>>choice; if(choice==1) { BuildList(); } if(choice==2) { cout<<"当前有如下文件,请选择读入文件: " if(! fileRecord) { cout<<"fileRecordisnotpresent! " } fileRecord>>fileNum; cout<<"当前有" fileRecord>>fileName[i]; cout ReadInfo(fileLoc-1); PrintList(); } cout<<"请选择您需要的操作: " (1)统计学生各科成绩" (2)删除某个学生成绩记录" if(operChoice==1) Statistic(); if(operChoice==2) 删除(); if(operChoice==3) Add(); if(operChoice==4) Sort(); Save(); ClearList(); } intmain() { cout<<"//////////////////////////////////" " s.Menu(); return0; }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据结构 课程设计 成绩管理系统