C++课程设计

图书信息:图书号、书名、作者名、分类号、出版单位、出版时间、价格、库存量。读者信息:借阅证号、姓名、性别、出生日期。派生以下两个类:学生读者(年级、系别、可借数量(其中:... 图书信息:图书号、书名、作者名、分类号、出版单位、出版时间、价格、库存量。
读者信息:借阅证号、姓名、性别、出生日期。
派生以下两个类:
学生读者(年级、系别、可借数量(其中:本科生10本(中文8本,外文2本),研究生(中文15本,外文5本)
教师读者(部门,可借数量(中文20本,外文10本)

试设计一图书信息管理系统,使之能提供以下功能:
(1)采编入库:新购入一本书,经分类和确定书号后登记到图书账目中去,若该书已存在,这库存量增加
(2)借阅:若一种书的现存量大于0,且借阅证还可借(未达最大借阅数或没有过期书目)该则借出一本,登记借阅者的图书证号和应归还期限
(3)归还:若过期要缴纳罚款,注销借阅者的登记,改变该书的现存量
(4)清除库存:某书已无保留价值,将它从图书账目中注销
(5)查询功能:--按书名查询(模糊查询) 按作者名或借阅证查询
这是图书管理系统!!!
展开
 我来答
蓝珮为何来146
2014-06-06 · 超过55用户采纳过TA的回答
知道答主
回答量:114
采纳率:0%
帮助的人:139万
展开全部
《C++课程设计》

课程设计题目:学生成绩管理系统

学生班级:*****

学生姓名:*****

学生学号:*****

(2)学生成绩管理系统需求与功能分析

学生成绩的录入、统计、查询、修改、删除、输出。 画出功能结构图。

(3)学生成绩管理系统的数据结构表

序号 成员名(字段名) 数据类型 长度 字段含义

1 class_0 char 20 班级

2 num int 学号

3 name char 8 姓名

4 elec flaot 电子技术

5 c_prog float C 程序设计

6 media flaot 多媒体技术

7 eng float 大学英语

8 math float 高等数学

9 sport float 大学体育

10 polity float 马克思主义政治经济学

11 ave float 平均成绩

12 order int 名次

(4)学生成绩管理系统测试数据表

class_0 num name elec c_prog media eng math sport polity ave order

网络30331 3033101 马云飞 80 70 60 70 70 60 80 表中其余数据自己编造。

(5)使用链表编写程序(手写源程序代码,并给出注解)

0)定义链表结点

1)主函数main():定义链表头指针,调用录入、统计等函数对成绩表进行处理;

2)建立链表函数Create():输入班级到政治课成绩信息;

3)统计函数Statistic():计算平均成绩;

4)查询函数Lookup():查询指定学号学生成绩记录;

5)修改函数Modify():修改指定学号学生成绩记录;

6)删除函数Delete():删除指定学号学生记录;

7)输出函数Output():输出班级所有学生成绩记录;

8)插入函数Insert():按平均分顺序插入新结点。

9) 排序函数Sort():按平均分对学生成绩记录项进行降序排序;

程序如下:

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

struct Node//定义链表结点
{

char* class_0;//班级
int number;
char* name;//姓名
float elec;//电子技术成绩
float c_prog;//C程序设计成绩
float media;//多媒体技术成绩
float eng;//大学英语成绩
float math;//高等数学成绩
float sport;//大学体育成绩
float polity;//马克思主义政治经济学成绩
float ave;//平均成绩
int order;//名次
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=new char[21];
strcpy(class_0,_class_0);
name=new char[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()
{
delete []class_0;
delete []name;
}

};
class StudentScore
{
private:
Node* first;//链表的头指针
int choice;//选择数据的读入方式
int fileNum;//当前文件数减一
int fileLoc;//定位当前文件
string* fileName;
int operChoice;
int RecordLength;
public:
StudentScore();
void Save();
void BuildList();//手工建立成绩链表
void ReadInfo(int k);//从内存中读入学生信息
void ClearList();
void Statistic();
void Sort();
void Add();
void Delete();
void PrintList();
void Menu();
};
StudentScore::StudentScore()
{
RecordLength=0;
operChoice=0;
first=NULL;
choice=0;
fileLoc=0;
fileNum=0;
fileName=new string[10];//最多可以存10个文件
}
int GetOrder(Node* first,float ave);
void StudentScore::BuildList()
{
int _number;//学号
char* _class_0=new char[21];//班级
char* _name=new char[9];//姓名
float _elec;//电子技术成绩
float _c_prog;//C程序设计成绩
float _media;//多媒体技术成绩
float _eng;//大学英语成绩
float _math;//高等数学成绩
float _sport;//大学体育成绩
float _polity;//马克思主义政治经济学成绩
float _ave;//平均成绩
int _order;//名次
char c;
Node *p,*r=NULL;
first=NULL;
cout<<"您要输入学生成绩信息?"<<endl;
while((c=getchar())=='n');
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=new Node(_number,_class_0,_name,_elec,
_c_prog,_media,_eng,_math,_sport,_polity,
_ave,_order,NULL);//建立一个新的结点储存信息

if(first!=NULL)
r->link=p;
else first=p;
r=p;
RecordLength++;
cout<<"您要输入学生成绩信息?"<<endl;
while((c=getchar())=='n');
}
}
int GetOrder(Node* first,float ave)//名次记录有严重问题
{
int order=1;
Node* temp=first;
for(;temp;temp=temp->link)
{ if(temp->ave>ave) order++;
if(temp->ave<ave) (temp->order)++;
}
return order;
}

void StudentScore::Statistic()
{
Node* temp=first;
float a_elec=0.0;//电子技术成绩
float a_c_prog=0.0;//C程序设计成绩
float a_media=0.0;//多媒体技术成绩
float a_eng=0.0;//大学英语成绩
float a_math=0.0;//高等数学成绩
float a_sport=0.0;//大学体育成绩
float a_polity=0.0;//马克思主义政治经济学成绩
int i=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<<"电子技术平均成绩为:"<<a_elec<<endl;
cout<<"c程序设计平均成绩为:"<<a_c_prog<<endl;
cout<<"多媒体技术平均成绩为:"<<a_media<<endl;
cout<<"英语平均成绩为:"<<a_eng<<endl;
cout<<"高等数学平均成绩为:"<<a_math<<endl;
cout<<"体育平均成绩为:"<<a_sport<<endl;
cout<<"政治平均成绩为:"<<a_polity<<endl;
}
void StudentScore::Delete()
{
int studNum;
Node* p;
Node* temp=first;
cout<<"请输入要删除的学生学号"<<endl;
cin>>studNum;
float average;
for(;temp;temp=temp->link)
{
cout<<temp->number;

if(temp->number==studNum)
{
average=temp->ave;

if(temp==first)//说明是第一次
{
first=first->link;
delete temp;
break;//如果不跳出的话 temp=temp->link会出错
}
else
{
p->link=temp->link;
delete temp;
break;
}
}
p=temp;
RecordLength--;

}
//下面修改学生排名
temp=first;
for(;temp;temp=temp->link)
if(temp->ave<average) temp->order--;

}
void StudentScore::Add()
{
int _number;//学号
char* _class_0=new char[21];//班级
char* _name=new char[9];//姓名
float _elec;//电子技术成绩
float _c_prog;//C程序设计成绩
float _media;//多媒体技术成绩
float _eng;//大学英语成绩
float _math;//高等数学成绩
float _sport;//大学体育成绩
float _polity;//马克思主义政治经济学成绩
float _ave;//平均成绩
int _order;//名次
char c;
Node *p,*r=NULL;
r=first;
while(r->link)
r=r->link;

// first=NULL;
cout<<"您要输入学生成绩信息?"<<endl;
while((c=getchar())=='n');
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=new Node(_number,_class_0,_name,_elec,
_c_prog,_media,_eng,_math,_sport,_polity,
_ave,_order,NULL);//建立一个新的结点储存信息

if(first!=NULL)
r->link=p;
else first=p;
r=p;
RecordLength++;
cout<<"您要输入学生成绩信息?"<<endl;
while((c=getchar())=='n');
}

}
void StudentScore::Sort()//简单bubble排序从高分到低分排序
{
int i=0;
Node* temp=first;
Node* before;
// Node* p=first;
for(;temp->link;)
{
if(temp->ave<temp->link->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(int j=0;j<i;j++)
{
if(temp->ave<temp->link->ave)
{
cout<<"small!"<<endl;
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;
}
}
}

}
/*
bool IsSorted(Node* first)
{
for(;first;first=first->link)
if(first->ave<first->link->ave) return false;
return true;
}*/

void StudentScore::PrintList()//打印链表程序
{
cout<<"The list contains:"<<endl;
Node* temp=first;
for(;temp;temp=temp->link)
{
cout<<temp->class_0<<","<<temp->name<<endl;
cout<<temp->order<<endl;
}
}

void StudentScore::ClearList()//清除链表
{
Node* p=new Node;
while(first)
{
p=first->link;
delete first;
first=p;
}
}

//读函数
void StudentScore::ReadInfo(int k)//读第k个文件的信息存入链表
{
// int wordLength;//记录子段长度
int _number;//学号
char* _class_0=new char[21];//班级
char* _name=new char[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;
ifstream Infile(fileName[k].c_str());
if(!Infile)
{
cout<<"file is not present!"<<endl;
return;
}
Infile>>RecordLength;
cout<<RecordLength;
for(int i=0;i<RecordLength;i++)
{
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=new Node(_number,_class_0,_name,_elec,
_c_prog,_media,_eng,_math,_sport,_polity,
_ave,_order,NULL);//建立一个新的结点储存信息

if(first!=NULL)
r->link=p;
else first=p;
r=p;
}

}
void StudentScore::Save()
{
string tempName;
cout<<"请输入将要保存的文件名:"<<endl;
//要判断是否跟现有文件重名
cin>>tempName;
ofstream savefile(tempName.c_str());//要做一个转换
Node* temp=first;
savefile<<RecordLength<<endl;
for(;temp;temp=temp->link)
{
savefile<<temp->class_0<<" "<<temp->number<<" "<<temp->name<<" "<<temp->elec<<" "
<<temp->c_prog<<" "<<temp->media<<" "<<temp->eng<<" "<<temp->math<<" "
<<temp->sport<<" "<<temp->polity<<" "<<temp->ave<<" "<<temp->order<<endl;
}
savefile.close();

//读取文件表信息
ifstream Readfileinfo("FileRecord.txt");
Readfileinfo>>fileNum;
for(int i=0;i<fileNum;i++)
Readfileinfo>>fileName[i];
Readfileinfo.close();
fileNum++;
fileName[i]=tempName;
//修改文件表信息
ofstream changefile("FileRecord.txt");
changefile<<fileNum<<endl;
for(i=0;i<fileNum;i++)
changefile<<fileName[i]<<endl;
changefile.close();
}

void StudentScore::Menu()
{
cout<<"请您选择数据的读入方式:"<<endl;
cout<<"(1) 重新手动建立一份新的数据表"<<endl;
cout<<"(2) 从文件中读入数据"<<endl;
cout<<"请选择:";
cin>>choice;
if(choice==1)
{
BuildList();
}
if(choice==2)
{
cout<<"当前有如下文件,请选择读入文件:"<<endl;
ifstream fileRecord("fileRecord.txt");
if(!fileRecord)
{
cout<<"fileRecord is not present!"<<endl;
return;
}
fileRecord>>fileNum;
cout<<"当前有"<<fileNum<<"个文件:"<<endl;
for(int i=0;i<fileNum;i++)
{
fileRecord>>fileName[i];
cout<<fileName[i]<<" ";
}
cout<<"请您选择一个文件:";
cin>>fileLoc;
ReadInfo(fileLoc-1);
PrintList();

}
cout<<"请选择您需要的操作:"<<endl;
cout<<"(1) 统计学生各科成绩"<<endl;
cout<<"(2) 删除某个学生成绩记录"<<endl;
cout<<"(3) 增加某个学生成绩记录"<<endl;
cout<<"(4) 在链表中为所有学生成绩记录排序"<<endl;
cin>>operChoice;
if(operChoice==1)
Statistic();
if(operChoice==2)
Delete();
if(operChoice==3)
Add();
if(operChoice==4)
Sort();
Save();
ClearList();
}

int main()
{
cout<<"//////////////////////////////////"<<endl;
cout<<"欢迎使用学生成绩管理系统!"<<endl;
cout<<"//////////////////////////////////"<<endl;
cout<<endl;
cout<<endl;
StudentScore s;
s.Menu();
return 0;
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式