<span style="color:#9999ff;">/*
*烟台大学计算机与控制工程学院
*作者:刘熠
*完成时间:2015年12月25日
*题目:学生信息管理系统设计
*/</span>
#ifndef HEAD_H_INCLUDED
#define HEAD_H_INCLUDED
using namespace std;
typedef struct student
{
int num;
char name[20];
char sex;
int age;
char category[20];
student *next;
} ElemType;
class List
{
private:
ElemType *head;//链表头指针
public:
void CreateList();//建立
void DispList();//显示
void ListInsert();//插入
void LocateElem();//查找
void Listchange();//修改
void ListDelete();//删除
List(){head=NULL;}
};//定义结构体,第一个结构体是数据结构课程中所学的只是,第二个是C++中的结构体,第二个结构体定义了所需要的函数
/* 文件名:*HEAD(1)。h
*该函数的目的是建立学生信息,将学生信息加入到系统中去
*/
void List::CreateList()//建立
{
ElemType *head1,*p;
cout<<"请输入学生信息以”0“结束输入"<<endl;
head=head1=new ElemType;
while(cin>>head1->num&&head1->num)
{
cin>>head1->name>>head1->sex>>head1->age>>head1->category;
p=new ElemType;
head1->next=p;
head1=p;
}
head1->next=NULL;
}
/*
*该函数的目的是显示所有学生的信息,运用了循环
*/
void List::DispList()//显示
{
ElemType *head1;
head1=head;
while(head1->next!=NULL)
{
cout<<"**************************"<<endl;
cout<<"学 号: "<<head1->num<<endl;
cout<<"姓 名: "<<head1->name<<endl;
cout<<"性 别: "<<head1->sex<<endl;
cout<<"年 龄: "<<head1->age<<endl;
cout<<"专 业: "<<head1->category<<endl;
cout<<"**************************"<<endl;
head1=head1->next;
}
}
/*
*该函数的目的是删除学生信息,但因为程序不够完美,所以删除的学生信息只能存在内存中,空间不能释放,浪费空间
*/
void List::ListDelete()//删除
{
int D_num;
ElemType *p1,*p2;
cout<<"请输入要删除的学生的学号,以0结束删除操作:"<<endl;
课程设计:学生信息管理系统设计
最新推荐文章于 2024-05-21 23:14:05 发布