终极的实验报告Word文档下载推荐.docx

上传人:b****4 文档编号:8243707 上传时间:2023-05-10 格式:DOCX 页数:33 大小:227.89KB
下载 相关 举报
终极的实验报告Word文档下载推荐.docx_第1页
第1页 / 共33页
终极的实验报告Word文档下载推荐.docx_第2页
第2页 / 共33页
终极的实验报告Word文档下载推荐.docx_第3页
第3页 / 共33页
终极的实验报告Word文档下载推荐.docx_第4页
第4页 / 共33页
终极的实验报告Word文档下载推荐.docx_第5页
第5页 / 共33页
终极的实验报告Word文档下载推荐.docx_第6页
第6页 / 共33页
终极的实验报告Word文档下载推荐.docx_第7页
第7页 / 共33页
终极的实验报告Word文档下载推荐.docx_第8页
第8页 / 共33页
终极的实验报告Word文档下载推荐.docx_第9页
第9页 / 共33页
终极的实验报告Word文档下载推荐.docx_第10页
第10页 / 共33页
终极的实验报告Word文档下载推荐.docx_第11页
第11页 / 共33页
终极的实验报告Word文档下载推荐.docx_第12页
第12页 / 共33页
终极的实验报告Word文档下载推荐.docx_第13页
第13页 / 共33页
终极的实验报告Word文档下载推荐.docx_第14页
第14页 / 共33页
终极的实验报告Word文档下载推荐.docx_第15页
第15页 / 共33页
终极的实验报告Word文档下载推荐.docx_第16页
第16页 / 共33页
终极的实验报告Word文档下载推荐.docx_第17页
第17页 / 共33页
终极的实验报告Word文档下载推荐.docx_第18页
第18页 / 共33页
终极的实验报告Word文档下载推荐.docx_第19页
第19页 / 共33页
终极的实验报告Word文档下载推荐.docx_第20页
第20页 / 共33页
亲,该文档总共33页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

终极的实验报告Word文档下载推荐.docx

《终极的实验报告Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《终极的实验报告Word文档下载推荐.docx(33页珍藏版)》请在冰点文库上搜索。

终极的实验报告Word文档下载推荐.docx

输出形式与输出形式类似,根据需要可以选择显示输入的各项内容。

1.1.1程序流程图:

1.2模块实现

1.2.1建立双向链表

classNode{…};

classCList{…};

1.2.2建立双向链表的派生类

classStack:

publicCList{…};

classQueue:

classSet:

publicCList

{

public:

friendCListoperator+(CLista,CListb);

friendCListoperator-(CLista,CListb);

friendCListoperator&

(CLista,CListb);

};

1.2.3构造函数

Node():

Constructsannewnode.

   CList():

Constructsanemptyorderedlist.

1.2.4获得头/尾指针

GetHead:

Returnstheheadelementofthelist

GetTail:

Returnsthetailelementofthelist

1.2.5链表操作

creat_head(Node*s);

Addsanelementtotheheadofthelist(makesanewhead).

creat_CList();

show_CList(CListL);

1.2.6遍历操作

GetNext:

Getsthenextelementforiterating.

GetPrev:

Getsthepreviouselementforiterating.

1.2.7检索/修改操作

GetAt:

Getstheelementatagivenposition.

SetAt:

Setstheelementatagivenposition.

RemoveAtRemovesanelementfromthislist,specifiedbyposition.

1.2.8插入操作

InsertBefore:

Insertsanewelementbeforeagivenposition.

InsertAfter:

Insertsanewelementafteragivenposition.

1.2.9查询操作

Find:

Getsthepositionofanelementspecifiedbypointervalue.

FindIndex:

Getsthepositionofanelementspecifiedbyazero-basedIndex.

1.2.10建立主菜单

intmain()

{

CListL;

CListL1,L2;

QueueQ1;

StackS1;

while

(1)

{

cin>

>

i;

switch(i)

case1:

(建立学生记录)

case2:

(插入学生记录)

case3:

(查询学生记录)

case4:

(删除学生记录)

case5:

(输出学生记录)

case6:

(修改学生记录)

case7:

(学生记录并集)

case8:

(学生记录差集)

case9:

(学生记录交集)

case10:

(队列式查询)

case11:

(栈式查询)

case12:

(退出管理系统)

}

1.3源代码:

#include<

windows.h>

//定义活动文本模式窗口,刷新功能system("

cls"

)清屏函数;

iostream>

#include<

string>

ctime>

//跟时间日期有关

usingnamespacestd;

classNode

public:

charname[10];

charsex[10];

intnum;

intscore;

Node*pre;

Node*next;

Node();

voidinit_node();

~Node();

};

//***********************************

Node:

:

Node()

pre=NULL;

next=NULL;

Node:

~Node()

}

voidNode:

init_node()

cout<

<

"

请输入学生的学号:

\t"

;

cin>

num;

请输入学生的姓名:

name;

请输入学生的性别:

sex;

请输入学生的分数:

score;

classCList

intlength;

Node*PHead;

Node*PTail;

CList(Node*head=NULL,Node*tail=NULL);

Node*get_head();

Node*get_tail();

Node*GetPrev(Node*p);

Node*GetNext(Node*p);

Node*GetAt(Node*head,intn);

voidcreat_head(Node*s);

voidcreat_CList();

voidshow_CList(CListL);

voidSetAt(Node*head,intn);

voidRemoveAt(Node*head,intn);

voidInsertAfter(Node*head,intn);

intFind(Node*head,Node*s);

intFindIndex(Node*head,inte);

~CList();

//************************************

CList:

CList(Node*head,Node*tail)

PHead=head;

PTail=tail;

~CList()

Node*CList:

get_head()

returnPHead;

get_tail()

returnPTail;

GetPrev(Node*p)

Node*q=p;

q=q->

pre;

returnq;

GetNext(Node*p)

next;

Node*CList:

GetAt(Node*head,intn)

Node*p=head;

inti=1;

while(i<

n)

p=p->

i++;

returnp;

voidCList:

creat_head(Node*s)

PHead=s;

creat_CList()

请输入链表长度(结点数):

"

length;

PHead=newNode;

Node*p,*q;

p=q=PHead;

p->

init_node();

for(inti=1;

i<

i++)

q=newNode;

q->

p->

next=q;

pre=p;

p=q;

PTail=q;

//**************************************

show_CList(CListL)

Node*head;

head=L.get_head();

while(head)

cout<

"

学号:

head->

num<

姓名:

name<

性别:

sex<

分数:

score<

endl;

head=head->

SetAt(Node*head,intn)

Node*q=newNode;

q->

n-1)

next=p->

next->

pre=q;

//******************************************

RemoveAt(Node*head,intn)

Node*q;

q=p->

next=q->

//*********************************************

InsertAfter(Node*head,intn)

n)

intCList:

Find(Node*head,Node*s)

while(p!

=s)

p=p->

returnp->

//********************************************

FindIndex(Node*head,inte)

while(p->

num!

=e)

//*******************************************

classStack:

Stack();

Node*get_top();

voidpush();

voidshow_Stack(Node*top);

Node*top;

//********************************

Stack:

Stack()

top=get_tail();

Node*Stack:

get_top()

returntop;

//*******************************

voidStack:

push()

{inti,m;

【入栈】请输入入栈长度(结点数):

m;

for(i=0;

{Node*p=newNode;

next=top;

top=p;

show_Stack(Node*top)

{cout<

【出栈】栈内全部信息:

Node*p=top;

while(p)

p->

}

//***************************************

classQueue:

publicCList

private:

Node*front;

Node*rear;

Queue();

voidEnQueue();

voidDeQueue();

Queue:

Queue()

front=get_head();

rear=get_tail();

voidQueue:

EnQueue()

【入队】请输入队列长度(结点数):

if(rear)

Node*p=newNode;

next=NULL;

rear->

next=p;

rear=p;

else

p->

front=rear=p;

}

//*************************************

DeQueue()//头出队

inti,m;

【出队】请输入输出队列长度(结点数)"

if(front)

front->

front=front->

队为空!

classSet:

public:

CListoperator+(CLista,CListb)

CListLa;

Node*s;

inti=0;

Node*p=a.get_head();

Node*q=b.get_head();

while(p)

Node*r=newNode;

strcpy(r->

name,p->

name);

sex,p->

sex);

r->

num=p->

score=p->

if(i==0)

{

La.creat_head(r);

s=r;

}

else

s->

next=r;

p=a.get_head();

while(q)

while(p)

if(p->

num==q->

num)

{

if(q->

next)

{

q=q->

p=a.get_head();

}

else

returnLa;

}

else

p=p->

name,q->

sex,q->

num=q->

score=q->

s=r;

}

q=q->

p=a.get_head();

returnLa;

CListoperator-(CLista,CListb)

if(p->

while(q)

if(p->

p=p->

q=b.get_head();

else

s->

else

}

La.creat_head(r);

i++;

}

q=b.get_head();

//*************************************************

CListoperator&

(CLista,CListb)

Node*r=NULL;

if(p-

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2