欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    《数据结构》课程设计试验报告.docx

    • 资源ID:2002660       资源大小:78.75KB        全文页数:16页
    • 资源格式: DOCX        下载积分:1金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要1金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    《数据结构》课程设计试验报告.docx

    1、数据结构课程设计试验报告 数据结构课程设计实验报告题 目 约瑟夫问题和八皇后问题求解 学 院 数学与信息工程学院 专 业 计算机科学与技术 班 级 计科081 学 号 200853225142 学生姓名 陈哲 同组成员 魏艳舞 杨青 施晓洁 吴亚君 徐珍艳 张素姿指导教师 刘小晶 编写日期 2009年6月28日 一、问题描述 1、约瑟夫问题描述 编号为1,2 n的n个人按顺时针方向围坐一圈,每人持有一个密码(正整数)。一开始任选一个正整数作为报数的上限值m,从第一个人开始按顺时针方向自1开始顺序报数,报到m时停止报数,报m的人出列,将他的密码作为新的m值,从他的顺时针方向上的下一个开始重新从1

    2、报数,如此下去,直至所有人全部出列为止,设计一个程序求出出列顺序。 2、八皇后问题描述在一个的棋盘里放置个皇后,要求每个皇后两两之间不相冲(在每一横列竖列斜列只有一个皇后)。3、界面设计模块问题描述 设计一个菜单式界面,让用户可以选择要解决的问题,同时可以退出程序。界面要求简洁明了,大方得体,便于用户的使用,同时,对于用户的错误选择可以进行有效的处理。二、问题分析本人负责的是为用户设计菜单界面,使用户可以根据菜单进行选择其中的某个问题进行处理。对于一个菜单界面,首先要求界面简单明了,使得用户可以轻松通过界面知道如何获取自己想要的操作。其次,我们不能保证用户每次的选择都是有效的,即用户的选择是在

    3、我们提供的服务范围之内,所以要设计容错操作,即当用户的选择超出我们提供的范围时,提示用户重新选择。最后,要保证用户选择相应的操作后,程序能正确的按照用户的选择运行下去,完成用户的要求。三、数据结构描述 Int choice; 记录用户的选择,然后选择相应的操作。 typedef struct LNode int num; int code; struct LNode *next; node,*linklist; 单链表解决约瑟夫问题时储存结点信息char a99; 八皇后问题中记录棋盘信息四、算法设计1、程序层次模块图 程序总层次模块图2、算法设计void jiemian() printf(

    4、the problem of people our of circlrn); printf( *n); printf( * 1.solve by lianbiao; *n); printf( * 2.solve by shunxubiao; *n); printf( * 3.help; *n); printf( * 4.ruturn to menu; *n); printf( *n); void help() printf( the problem of people our of circlrn); printf(*n); printf(* you can choise 1,2,3 or 4

    5、 to get the function you want.if you choise 1, *n); printf(* you will solve the problem by lianbiao.in this way,when a people out of *n); printf(* the circle,the node which contain his message will be deleted.if you *n); printf(* choise 2,you will solve the problem by shunxubiao.in this way,when a *

    6、n); printf(* people out of the circle,his code will change into 0,but his message *n); printf(* will be remained.if you choise 4,end the game. *n); printf(*n);void welcome() printf( welcome to our systemn); printf( *n); printf( * 1.Joseph Central issues *n); printf( * 2.Queen 8 *n); printf( * 3.exit

    7、 *n); printf( *n); int main() int choice; welcome(); printf( please make your choice:); scanf(%d,&choice); while(choice!=3) switch(choice) case 1:system(cls);Joseph();getch();break; case 2:system(cls);Queen();getch();getch();break; default:printf( please chooose the right choice!);getch();getch();br

    8、eak; system(cls); welcome(); printf( please make your choice:); scanf(%d,&choice); 五、详细程序清单#include#includetypedef struct LNode int num; int code; struct LNode *next; node,*linklist; /数据结构声明char a99;int total;linklist creatstart(linklist L,int number) /建立单向循环链表 int m,i; linklist s,p; s=L; for(i=1;in

    9、um=i; printf(please input the code of number %d:,i); scanf(%d,&p-code); p-next=NULL; s-next=p; s=p; s-next=L-next; return s;void chulie(linklist L,int number) /链表中的出列 int turn,i,j; linklist p,s; printf(please input the start code:); scanf(%d,&turn); p=L; printf(the turn out of the circle is:); for(i

    10、=1;i=number-1;i+) for(j=1;jnext; printf(%d ,p-next-num); turn=p-next-code; s=p-next; p-next=s-next; free(s); printf(%d ,p-next-num); printf(n);void lianbiao() /用单向循环链表解决约瑟夫问题 int number; linklist L; L=(linklist)malloc(sizeof(node); if(!L) exit(0); printf(please input the number of people:); scanf(%d

    11、,&number); L=creatstart(L,number); chulie(L,number);void jiemian() /约瑟夫问题的界面 printf( the problem of people our of circlrn); printf( *n); printf( * 1.solve by lianbiao; *n); printf( * 2.solve by shunxubiao; *n); printf( * 3.help; *n); printf( * 4.ruturn to menu; *n); printf( *n); void shunxubiao() /用

    12、顺序表解决约瑟夫问题 int a500=0,i,code,number,shu; printf(please input the number of people:); scanf(%d,&number); shu=number; for(i=1;i0) while(code0) if(i+1number) i=0; if(ai+1!=0) code-; i+; printf(%d ,i); code=ai; ai=0; shu-; printf(n);void help() /帮助文档 printf( the problem of people our of circlrn); printf

    13、(*n); printf(* you can choise 1,2,3 or 4 to get the function you want.if you choise 1, *n); printf(* you will solve the problem by lianbiao.in this way,when a people out of *n); printf(* the circle,the node which contain his message will be deleted.if you *n); printf(* choise 2,you will solve the pr

    14、oblem by shunxubiao.in this way,when a *n); printf(* people out of the circle,his code will change into 0,but his message *n); printf(* will be remained.if you choise 4,end the game. *n); printf(*n);void Joseph() /约瑟夫问题 int choice; jiemian(); printf( please make your choice:); scanf(%d,&choice); whi

    15、le(choice!=4) switch(choice) case 1:lianbiao();getch();getch();break; case 2:shunxubiao();getch();getch();break; case 3:system(cls);help();getch();getch();break; default:printf( please chooose the right choice!);getch();getch();break; system(cls); jiemian(); printf( please make your choice:); scanf(

    16、%d,&choice); void init() /八皇后问题棋盘初始化 int i,j; for(i=1;i=8;i+) for(j=1;j=8;j+) aij=*;void shuchu() /输出可行解 int i,j; for(i=1;i=8;i+) for(j=1;j=8;j+) printf(%c ,aij); printf(n); printf(n);void digui(int hang) /递归解决八皇后问题 int lie; for(lie=1;lie=8;lie+) if(panduan(hang,lie) ahanglie=; if(hang!=8) digui(han

    17、g+1); else shuchu(); total+; ahanglie=*; int panduan(int hang,int lie) /判断能否放置皇后 int i,j; for(i=1;ihang;i+) if(ailie=) return 0; for(i=1;i0)&(j-10) if(ai-1j-1=) return 0; i-; j-; i=hang; j=lie; while(i-10)&(j+1=8) if(ai-1j+1=) return 0; i-; j+; return 1;void Queen() /八皇后问题 digui(1); printf(the total

    18、 possibility is:%dn,total);void welcome() /主程序界面 printf( welcome to our systemn); printf( *n); printf( * 1.Joseph Central issues *n); printf( * 2.Queen 8 *n); printf( * 3.exit *n); printf( *n); int main() /主函数 int choice; welcome(); printf( please make your choice:); scanf(%d,&choice); while(choice!

    19、=3) switch(choice) case 1:system(cls);Joseph();getch();break; case 2:system(cls);Queen();getch();getch();break; default:printf( please chooose the right choice!);getch();getch();break; system(cls); welcome(); printf( please make your choice:); scanf(%d,&choice); 六、程序运行结果七、使用说明用户进入主界面后根据菜单内容选择1、2、3分别可进行约瑟夫问题、八皇后问题、退出系统操作。进入约瑟夫问题后按照菜单选择1、2、3、4分别可进行链表求解、顺序表求解、查看帮助文档、回到主菜单操作。进入八皇后问题系统即可输出所有的可能解,并计算解的数目。八、心得体会 良好的界面不仅能反映出程序的主题结构,让用户了解系统的答大体功能,同时可以极大地方便用户随系统的了解与使用,增加用户与系统的交互性。


    注意事项

    本文(《数据结构》课程设计试验报告.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

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


    收起
    展开