《数据结构》课程设计试验报告Word文件下载.docx

上传人:b****1 文档编号:3716137 上传时间:2023-05-02 格式:DOCX 页数:16 大小:78.75KB
下载 相关 举报
《数据结构》课程设计试验报告Word文件下载.docx_第1页
第1页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第2页
第2页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第3页
第3页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第4页
第4页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第5页
第5页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第6页
第6页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第7页
第7页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第8页
第8页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第9页
第9页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第10页
第10页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第11页
第11页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第12页
第12页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第13页
第13页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第14页
第14页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第15页
第15页 / 共16页
《数据结构》课程设计试验报告Word文件下载.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

《数据结构》课程设计试验报告Word文件下载.docx

《《数据结构》课程设计试验报告Word文件下载.docx》由会员分享,可在线阅读,更多相关《《数据结构》课程设计试验报告Word文件下载.docx(16页珍藏版)》请在冰点文库上搜索。

《数据结构》课程设计试验报告Word文件下载.docx

界面要求简洁明了,大方得体,便于用户的使用,同时,对于用户的错误选择可以进行有效的处理。

二、问题分析

本人负责的是为用户设计菜单界面,使用户可以根据菜单进行选择其中的某个问题进行处理。

对于一个菜单界面,首先要求界面简单明了,使得用户可以轻松通过界面知道如何获取自己想要的操作。

其次,我们不能保证用户每次的选择都是有效的,即用户的选择是在我们提供的服务范围之内,所以要设计容错操作,即当用户的选择超出我们提供的范围时,提示用户重新选择。

最后,要保证用户选择相应的操作后,程序能正确的按照用户的选择运行下去,完成用户的要求。

三、数据结构描述

Intchoice;

记录用户的选择,然后选择相应的操作。

typedefstructLNode{

intnum;

intcode;

structLNode*next;

}node,*linklist;

单链表解决约瑟夫问题时储存结点信息

chara[9][9];

八皇后问题中记录棋盘信息

四、算法设计

1、程序层次模块图

程序总层次模块图

2、算法设计

voidjiemian()

{

printf("

theproblemofpeopleourofcirclr\n"

);

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

*1.solvebylianbiao;

*\n"

*2.solvebyshunxubiao;

*3.help;

*4.ruturntomenu;

}

voidhelp()

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

*youcanchoise1,2,3or4togetthefunctionyouwant.ifyouchoise1,*\n"

*youwillsolvetheproblembylianbiao.inthisway,whenapeopleoutof*\n"

*thecircle,thenodewhichcontainhismessagewillbedeleted.ifyou*\n"

*choise2,youwillsolvetheproblembyshunxubiao.inthisway,whena*\n"

*peopleoutofthecircle,hiscodewillchangeinto0,buthismessage*\n"

*willberemained.ifyouchoise4,endthegame.*\n"

voidwelcome()

welcometooursystem\n"

*1.JosephCentralissues*\n"

*2.Queen8*\n"

*3.exit*\n"

}

intmain()

intchoice;

welcome();

pleasemakeyourchoice:

"

scanf("

%d"

&

choice);

while(choice!

=3)

{

switch(choice)

case1:

system("

cls"

Joseph();

getch();

break;

case2:

Queen();

default:

printf("

pleasechooosetherightchoice!

}

system("

五、详细程序清单

#include<

stdio.h>

conio.h>

typedefstructLNode{

//数据结构声明

inttotal;

linklistcreatstart(linklistL,intnumber)//建立单向循环链表

{

intm,i;

linklists,p;

s=L;

for(i=1;

i<

=number;

i++)

{

p=(linklist)malloc(sizeof(node));

if(!

p)exit(0);

p->

num=i;

pleaseinputthecodeofnumber%d:

i);

p->

code);

p->

next=NULL;

s->

next=p;

s=p;

next=L->

next;

returns;

voidchulie(linklistL,intnumber)//链表中的出列

intturn,i,j;

linklistp,s;

pleaseinputthestartcode:

turn);

p=L;

theturnoutofthecircleis:

=number-1;

for(j=1;

j<

=turn-1;

j++)p=p->

%d"

p->

next->

num);

turn=p->

code;

s=p->

next=s->

free(s);

\n"

voidlianbiao()//用单向循环链表解决约瑟夫问题

intnumber;

linklistL;

L=(linklist)malloc(sizeof(node));

L)exit(0);

pleaseinputthenumberofpeople:

number);

L=creatstart(L,number);

chulie(L,number);

voidjiemian()//约瑟夫问题的界面

voidshunxubiao()//用顺序表解决约瑟夫问题

inta[500]={0},i,code,number,shu;

shu=number;

printf("

a[i]);

i=0;

while(shu>

0)

while(code>

0)

{

if(i+1>

number)i=0;

if(a[i+1]!

=0)code--;

i++;

}

code=a[i];

a[i]=0;

shu--;

voidhelp()//帮助文档

voidJoseph()//约瑟夫问题

jiemian();

=4)

lianbiao();

shunxubiao();

case3:

help();

voidinit()//八皇后问题棋盘初始化

inti,j;

=8;

j++)

a[i][j]='

*'

;

voidshuchu()//输出可行解

%c"

a[i][j]);

voiddigui(inthang)//递归解决八皇后问题

intlie;

for(lie=1;

lie<

lie++)

if(panduan(hang,lie))

a[hang][lie]='

@'

if(hang!

=8)digui(hang+1);

else

{

shuchu();

total++;

}

a[hang][lie]='

intpanduan(inthang,intlie)//判断能否放置皇后

hang;

if(a[i][lie]=='

)return0;

lie;

if(a[hang][i]=='

i=hang;

j=lie;

while((i-1>

0)&

&

(j-1>

0))

if(a[i-1][j-1]=='

i--;

j--;

(j+1<

=8))

if(a[i-1][j+1]=='

i--;

j++;

return1;

voidQueen()//八皇后问题

digui

(1);

thetotalpossibilityis:

%d\n"

total);

voidwelcome()//主程序界面

intmain()//主函数

六、程序运行结果

七、使用说明

用户进入主界面后根据菜单内容选择1、2、3分别可进行约瑟夫问题、八皇后问题、退出系统操作。

进入约瑟夫问题后按照菜单选择1、2、3、4分别可进行链表求解、顺序表求解、查看帮助文档、回到主菜单操作。

进入八皇后问题系统即可输出所有的可能解,并计算解的数目。

八、心得体会

良好的界面不仅能反映出程序的主题结构,让用户了解系统的答大体功能,同时可以极大地方便用户随系统的了解与使用,增加用户与系统的交互性。

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

当前位置:首页 > 幼儿教育 > 幼儿读物

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

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