数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx

上传人:b****6 文档编号:22480714 上传时间:2023-02-04 格式:DOCX 页数:25 大小:27.16KB
下载 相关 举报
数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx_第1页
第1页 / 共25页
数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx_第2页
第2页 / 共25页
数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx_第3页
第3页 / 共25页
数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx_第4页
第4页 / 共25页
数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx

《数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx》由会员分享,可在线阅读,更多相关《数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx(25页珍藏版)》请在冰豆网上搜索。

数据结构毕业课程设计报告迷宫求解问题Word文件下载.docx

\n"

);

scanf("

%d"

&

size);

if(size<

1||size>

10){printf("

输入错误!

"

return;

}

Initmaze(maze,size);

printmaze(maze,size);

PosTypestart,end;

输入入口行坐标和列坐标:

scanf("

start.row);

start.line);

输入出口行坐标和列坐标:

end.row);

end.line);

if(MazePath(maze,S,start,end))

printpath(maze,S,size);

elseprintf("

找不到通路!

\n\n"

StatusMazePath(intmaze[12][12],SqStack&

S,PosTypestart,PosTypeend)

PosTypecurpos;

intcurstep;

SElemTypee;

InitStack(S);

curpos=start;

curstep=1;

do{

if(Pass(maze,curpos))

{

Markfoot(maze,curpos);

e.di=1;

e.ord=curstep;

e.seat=curpos;

Push(S,e);

if(curpos.row==end.row&

&

curpos.line==end.line)

returnOK;

curpos=NextPos(curpos,1);

curstep++;

}

else

{

if(!

StackEmpty(S))

Pop(S,e);

while(e.di==4&

!

Markfoot(maze,e.seat);

if(e.di<

4)

e.di++;

Push(S,e);

curpos=NextPos(e.seat,e.di);

}while(!

StackEmpty(S));

returnERROR;

}

voidInitmaze(intmaze[12][12],intsize)

charselect;

printf("

选择创建方式A:

自动生成B:

手动创建\n"

label:

%c"

select);

if(select=='

a'

||select=='

A'

for(inti=0;

i<

size+2;

i++)maze[0][i]=1;

for(i=1;

size+1;

i++)

maze[i][0]=1;

for(intj=1;

j<

j++)

maze[i][j]=rand()%2;

maze[i][size+1]=1;

}

for(i=0;

i++)maze[size+1][i]=1;

elseif(select=='

b'

B'

按行输入%d*%d数据,0代表可通,1代表不可通(每行以Enter结束):

size,size);

maze[i][j]);

\n'

)gotolabel;

voidprintmaze(intmaze[12][12],intsize)

显示所建的迷宫(#表示外面的墙):

i++)printf("

%c"

'

#'

for(i=1;

%d"

maze[i][j]);

voidprintpath(intmaze[12][12],SqStackS,intsize)

\n\n通路路径为:

SElemType*p=S.base;

while(p!

=S.top)

maze[p->

seat.row][p->

seat.line]=2;

p++;

if(maze[i][j]==2)printf("

0'

"

StatusPass(intmaze[12][12],PosTypeCurPos)

if(maze[CurPos.row][CurPos.line]==0)

elsereturnERROR;

voidMarkfoot(intmaze[12][12],PosTypeCurPos)

maze[CurPos.row][CurPos.line]=1;

PosTypeNextPos(PosTypeCurPos,intDir)

PosTypeReturnPos;

switch(Dir)

case1:

ReturnPos.row=CurPos.row;

ReturnPos.line=CurPos.line+1;

break;

case2:

ReturnPos.row=CurPos.row+1;

ReturnPos.line=CurPos.line;

case3:

ReturnPos.line=CurPos.line-1;

case4:

ReturnPos.row=CurPos.row-1;

returnReturnPos;

StatusInitStack(SqStack&

S.base=(SElemType*)malloc(100*sizeof(SElemType));

if(!

S.base)returnERROR;

S.top=S.base;

S.stacksize=100;

returnOK;

StatusPush(SqStack&

S,SElemType&

a)

*S.top++=a;

StatusPop(SqStack&

if(S.top==S.base)returnERROR;

a=*--S.top;

StatusStackEmpty(SqStackS)

if(S.top==S.base)returnOK;

以下为测试数据:

输入一个矩阵,例如:

10011

00111

10001

01011

11000

输入入口行坐标和列坐标:

12

输入出口行坐标和列坐标:

55

通路路径为:

课题设计3:

joseph环

利用单向循环链表存储结构模拟此过程,按照出列的顺序输出各个人的编号。

首先创建一个空链表,初始化链表,构造出一个只有头结点的空链表,建立好一个约瑟夫环。

1.输入的形式和输入值的范围

本程序中,输入报数上限值m和人数上限l,密码,均限定为正整数,输入的形式为一个以“回车符”为结束标志的正整数。

2.输出的形式

从屏幕显示出列顺序。

3.程序功能

提供用户从键盘输入,Joseph约瑟夫环的必要数据,并显示出列顺序。

二、 

概要设计

以单向循环链表实现该结构。

1.抽象数据类型的定义为:

ADTLNode

D={ai|ai∈CharSet,i=1,2,…,n,n≥0}

R1={&

lt;

ai-1,ai&

gt;

|ai∈D,I=2,…,n}

三.源程序:

stdio.,Link&

L)初始化链表

Linkp,q;

q=L;

for(inti=1;

=n;

i++)

p=(Node*)malloc(sizeof(Node));

if(!

p)exit

(1);

thekey_%dis:

i);

p->

key);

p->

num=i;

L->

next=p;

L=p;

next=q->

next;

free(q);

voidmain()

LinkL,p,q;

intn,x;

L=NULL;

InitList(L);

构造出一个只有头结点的空链表

pleaseinputthetotlenumberofpeople:

n);

总共的人数n

thestartkeyis:

x);

初始密码为x

Creater(n,L);

建立好一个约瑟夫环

p=L;

x;

j++)

p=p->

q=p->

x=q->

key;

q->

num);

四、测试数据:

m的初值为20,n=7,7个人的密码依次为3,1,7,2,4,7,4

输出:

6741532

课题设计4:

商品货架管理

1、需求分析:

设计一个算法,每一次上货后始终保持生产日期越近的商品越靠近栈底。

求货架上剩余货物M、每天销售件数N、员工每天上货工作时间T,三者之间有何关系及T的最小值。

2、源程序:

iostream.top;

boolempty()

returntop==0;

};

voidmain()

seqstackc[k+1];

存放k种商品的数组,用c[0]来做中介货架

intTxq[k+1];

第i种取货用的时间

intTxs[k+1];

第i种上货用的时间

intNx[k+1];

第i种每天的销售数量

intN=0;

每天销售总量

intTx[k+1];

第i种每天上货的总时间

intT=0;

每天上货用的总时间

charyn='

Y'

;

for(inti=1;

=k;

cout<

<

******************************"

endl;

商品货架管理系统"

Nodestore[20];

charyear,month;

intcount;

货架上第i种商品的数目

intx,d,m,y;

x为第i种商品的序号

请输入货架上第"

种货物的详细信息:

(序号,生产日期(年、月、日如2006.2.13),现在货架上的存货数目,上货用时和取货用时)"

cin>

>

x>

y>

year>

m>

month>

d>

count>

Txs[i]>

Txq[i];

Nx[i]=maxsize-count;

货架上还需上"

货物"

Nx[i]<

件"

Tx[k]=Txs[i]*(maxsize+count)+2*Txq[i]*count;

该货架满货需要用时"

Tx[k]<

是否要上货?

(YN)"

yn;

if(yn=='

||yn=='

y'

intnumbers,nian,yue,ri;

请输入要上货物的数目及生产日期(年、月、日)"

上的是同一日期生产的货物

numbers>

nian>

yue>

ri;

if(numbers>

maxsize-count)

要上的货物数目超出了货架的最大容量,请重新输入"

for(intj=1;

=numbers;

N+=Nx[i];

T+=Tx[i];

每天销售总量为:

N<

每天上货用的总时间为:

T<

3、测试结果:

五、课程设计5:

航空客运订票系统

对于本设计,可采用基数排序法对于一组具有结构特点的飞机航班号进行排序,利用二分查找法对排好序的航班记录按航班号实现快递查找,按其他次关键字的查找可采用最简单的顺序查找方法进行,因为它们用的较少。

#include<

stdio.7

#defineradix_n10

#defineradix_c26

typedefcharkeytype;

typedefstruct

charstart[6];

charend[6];

charsche[10];

chartime1[5];

chartime2[5];

charmodel[4];

intprice;

}infotype;

typedefstruct

keytypekeys[keylen];

infotypeothers;

intnext;

}slnode;

slnodesl[maxspace];

intkeynum;

intlength;

}sllist;

typedefintarrtype_n[radix_n];

typedefintarrtype_c[radix_c];

voiddistribute(slnode*sl,inti,arrtype_nf,arrtype_ne)

intj,p;

for(j=0;

radix_n;

f[j]=e[j]=0;

for(p=sl[0].next;

p;

p=sl[p].next)

j=sl[p].keys[i]%48;

f[j])

f[j]=p;

else

sl[e[j]].next=p;

e[j]=p;

voidcollect(slnode*sl,inti,arrtype_nf,arrtype_ne)

intj,t;

!

f[j];

j++);

sl[0].next=f[j];

t=e[j];

while(j<

radix_n-1)

for(j=j+1;

radix_n-1&

if(f[j])

sl[t].next=f[j];

sl[t].next=0;

voiddistribute_c(slnode*sl,inti,arrtype_cf,arrtype_ce)

radix_c;

j=sl[p].keys[i]%65;

voidcollect_c(slnode*sl,inti,arrtype_cf,arrtype_ce)

radix_c-1)

radix_c-1&

voidradixsort(sllist&

l)链式

inti;

arrtype_nfn,en;

arrtype_cfc,ec;

for(i=0;

l.length;

l.sl[i].next=i+1;

l.sl[l.length].next=0;

for(i=l.keynum-1;

i>

=2;

i--)

distribute(l.sl,i,fn,en);

collect(l.sl,i,fn,en);

=0;

distribute_c(l.sl,i,fc,ec);

collect_c(l.sl,i,fc,ec);

voidarrange(sllist&

l)重新整理

intp,q,i;

slnodetemp;

p=l.sl[0].next;

while(p<

i)

p=l.sl[p].next;

q=l.sl[p].next;

if(p!

=i)

temp=l.sl[p];

l.sl[p]=l.sl[i];

l.sl[i]=temp;

l.sl[i].next=p;

p=q;

intbinsearch(sllistl,keytypekey[])

intlow,mid;

elseif(strcmp(key,l.sl[mid].keys)<

0)

0;

voidseqsearch(sllistl,keytypekey[],inti)

intj,k,m=0;

*************************************************************\n"

*航班号起点站终点站航班期起飞时间到达时间机型票价*\n"

for(j=1;

=l.length;

switch(i)

case2:

k=strcmp(key,l.sl[j].others.start);

break;

case3:

k=strcmp(key,l.sl[j].others.end);

case4:

k=strcmp(key,l.sl[j].others.time1);

case5:

k=strcmp(key,l.sl[j].others.time2);

if(k==0)

m=1;

*%-8s%-7s%-6s%-11s%-9s%-7s%-5s%4d*\n"

l.sl[j].keys,l.sl[j].others.start,l.sl[j].others.end,l.sl[j].others.sche,l.sl[j].others.time1,l.sl[j].others.time2,l.sl[j].others.model,l.sl[j].others.price);

if(m==0)

*无此航班信息,可能是输入错误!

*\n"

voidsearchcon(sllistl)

keytypekey[keylen];

inti=1,k;

while(i>

=1&

i

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

当前位置:首页 > 工作范文 > 演讲主持

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1