⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 student.h

📁 这是学生通讯管理系统哦.........................
💻 H
字号:
#include<iostream.h>
struct Student			//学生资料
{
	double No;
	char Name[20];
	int Birthday;
	char Sex[4];
	char TelNo[20];
	char Address[100];
};
struct STLinkNode		//链结点
{
	Student data;
	STLinkNode *next;
};
class STLinkList		//链
{
public:
	STLinkNode *head,*tail,*currptr;
	STLinkList()
	{
		head=tail=currptr=new STLinkNode;
		currptr->next=NULL;
	}
	void InsterHead(Student x);
	void InsterTail(Student x);
	void Del(int n);
	void Output(int n);
	void Output();
};
						//头插入
void STLinkList::InsterHead(Student x)
{
	currptr=new STLinkNode;
	currptr->data=x;
	currptr->next=head->next;
	head->next=currptr;
	if(tail->next==currptr)
		tail=currptr;
}
						//尾插入
void STLinkList::InsterTail(Student x)
{
	currptr=new STLinkNode;
	currptr->next=NULL;
	currptr->data=x;
	tail->next=currptr;
	tail=currptr;
}
						//删除结点
void STLinkList::Del(int n)
{
	STLinkNode *p;
	currptr=head->next;
	p=head;
	while(currptr!=NULL&&currptr->data.No!=n)
	{
		p=p->next;
		currptr=currptr->next;
	}
	if(currptr==NULL)
		cout<<"没有此号的学生!"<<endl;
	else
	{
		p->next=currptr->next;
		currptr->next=NULL;
		delete currptr;
	}
}
						 //输出学生
void STLinkList::Output(int n)
{
	currptr=head->next;
	while(currptr!=NULL&&currptr->data.No!=n)
	currptr=currptr->next;
	if(currptr==NULL)
		cout<<"没有此号的学生!"<<endl;
	else
	{
		cout<<"****************************************************************"<<endl;
		cout<<"该学生的信息如下:"<<endl;
		cout<<"学号:"<<currptr->data.No<<endl;
		cout<<"姓名:"<<currptr->data.Name<<endl;
		cout<<"性别:"<<currptr->data.Sex<<endl;	
		cout<<"出生日期:"<<currptr->data.Birthday<<endl;
		cout<<"电话号码:"<<currptr->data.TelNo<<endl;
		cout<<"地址:"<<currptr->data.Address<<endl;
		cout<<"****************************************************************"<<endl;
	}
}
						//输出内容
void STLinkList::Output()
{
	cout<<"                   学生通信录"<<endl;
	currptr=head->next;
	while(currptr!=NULL)
	{
		cout<<"****************************************************************"<<endl;
		cout<<"学号:"<<currptr->data.No<<endl;
		cout<<"姓名:"<<currptr->data.Name<<endl;
		cout<<"性别:"<<currptr->data.Sex<<endl;	
		cout<<"出生日期:"<<currptr->data.Birthday<<endl;
		cout<<"电话号码:"<<currptr->data.TelNo<<endl;
		cout<<"地址:"<<currptr->data.Address<<endl;
		currptr=currptr->next;
	}
	cout<<"****************************************************************"<<endl;
}
void ma(STLinkList &A)
{
	Student ST1={05601,"柴小坤",86,"男","020-85215414","华南师范大学西二414"};
	A.InsterTail(ST1);
	Student ST2={05602,"郑谢生",86,"男","020-58215414","华南师范大学西二414"};
	A.InsterTail(ST2);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -