C++选课管理系统课程设计.doc
文本预览下载声明
///////////////////////////////////////////////////////////////
//头文件及函数声明
#includeiostream
#include stdlib.h
#include conio.h
#includefstream
#includestring
#includeiomanip
using namespace std;
class XS;
class JS;
class stu;
class subject ;
int menu();//主菜单
int menu1();//学生选课端菜单
int menu2();//管理端菜单
template class T
void ADD(T P);//增加功能函数模板
template class T
void LOOK(T P) ;//查看功能函数模板
template class T
void DELETE(T P);//删除功能函数模板
void xuanke(XS P,char nu[],char na[]);//选课功能函数
void tuixuan(XS P,char nu[],char na[]);//退选课程功能函数
void lookyixuan(XS P,char nu[],char na[]);//查看学生已选课程函数
void dayin(XS P,char nu[],char na[]);//打印学生选课情况函数
void tuichu(); //退出系统函数
void password();//密码检查功能函数
/////////////////////////////////////////////
//定义课程信息类
struct course
{char cnum[10];
char cname[20];
char cteacher[20];
float credit;
};
struct Course
{course kecheng;
Course *next;
};
class subject
{Course *head; //头指针
Course *p; //当前指针
public:
subject(){head=p=NULL;} ;
void Add();
void Delete(); //删除课程
int Search(char nu[]); //根据课程号查找课程
void ReadFile(); //从文件中读取课程信息
void WriteFile(); //向文件写入课程信息
void Display(); //在屏幕中输出全部课程信息
friend XS;
friend JS;
friend void xuanke(XS P,char nu[],char na[]);
};
void subject::Add()
{p=new Course;
cout \t 请输入课程号:;cinp-kecheng.cnum;
if(Search(p-kecheng.cnum)==0)
{cout \t 请输入课程名:;cinp-kecheng.cname;
cout \t 请输入任课教师:;cinp-kecheng.cteacher;
cout \t 请输入课程学分:;cinp-kecheng.credit;
p-next=head; //头插入建链表
head=p;
cout增加课程操作成功!endl;
}
else
cout\n\t已经存在该课程,不能重复添加!endl;
}
void subject::Delete() //按课程号删除
{ if(head!=NULL)
{int n=0;
Course *kc=head;
Course *q1=head,*q2=head-next ;
char kh[10];
cout \t 请输入您要删除的课程号:;
cinkh;
while(kc!=NULL)
{n++;
if(strcmp(kc-kecheng.cnum,kh)==0) break;
kc=kc-next;
}
if(kc==NULL)cout不存在该课程号!endl;
else
{if(n==1)head=head-next;
else
{for(int i=1;in-1;i++)
{q1=q2
显示全部