数据结构与算法单源最短路径问题c++求解(Data structure and algorithm, single source, shortest path problem, c++ solution).docVIP
- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
数据结构与算法单源最短路径问题c求解(Datastructureandalgorithm,singlesource,shortestpathproblem,csolution)
数据结构与算法单源最短路径问题c++求解(Data structure and algorithm, single source, shortest path problem, c++ solution) #包含iostream #包括字符串 使用名称空间; 无穷= 整数矩阵; 国际num_point; 无效menu(); 空函数(int选择); 无效showmatrix(); 无效的路径(int source_point); 无效的路径导航(int * finaldistance,int * finalpath,int source_point); 国际main() { 矩阵= null; num_point = 0; menu(); int的选择; 选择; 而(选择)!= 0) { 功能(选择); menu(); 选择; } 返回0; } 无效menu() /菜单栏 { cout “********************” endl; cout “1。建立有向网” endl; cout “2。求单元最短路径” endl; cout “3。退出” endl; cout “********************” endl; } 函数(int选择)/功能函数 { 如果(选择= 1) { int信息[ 3 ]; cout “请输入顶点的个数:“ endl; num_point CIN; 矩阵=新的int * [ num_point ]; 为(int i = 0;i num_point;i++) { 矩阵[我] =新国际[ num_point ]; memset(矩阵[我],1,num_point * sizeof(int));//赋初值为无穷大 矩阵[ i ] 0; } cout “请按照三元组的形式输入各点信息(起点,终点,权值)“ endl; cout “以(0,0,0)结束输入” endl; 对于(int = i 0;i 3;i + +) { 信息[ i ]; } 而(信息[ 0 ]!= 0) { 矩阵[信息0 - 1 ] [信息1 - 1 ] =信息[ 2 ]; 对于(int = i 0;i 3;i + +) { 信息[ i ]; } } cout “有向网建立成功:“ endl; showmatrix(); } 否则如果(选择= 2) { 国际source_point; cout “请输入您所选定的源点:“ endl; source_point CIN; 最短路径(source_point); } 否则如果(选择= 3) { 出口(0); } } 无效的路径(int source_point)/求单源最短路 { int * =新国际[ num_point ];//记录哪些点的最短路径已经确定 int * finaldistance =新国际[ num_point ];//记录从源点到其他各点的最短长度 int * finalpath =新国际[ num_point ];//记录最短长度对应的路径 memset(s,0,num_point * sizeof(int));//初始话的数组 为(int i = 0;i num_point;i++) { finaldistance [我] =矩阵[ source_point-1 ] [我];//初始化finaldistance数组 如果(finaldistance [我] 无限) { finalpath [我] = source_point-1; } 其他的 { finalpath [我] =无限; } } S[source_point-1] = 1; / / the shortest distance from the source point to the source point has been determined Int max = infinite; Int prime = source_point-1; Int progress = 0; While (Progress num_point-1) { Max = infinite; For (int i=0; inum_point; i++) { If (finalDistance[i]max = = 0 s[i]) { Max = finalDistance[i]; Prime = i; } } S[prime] = 1; For (int i=0; inum_point; i++) { If (finalDistance[i]finalDistance[prime] + matrix[prime][i]) { FinalDistance[i
您可能关注的文档
- 04打造高效执行力组织第三步(04, to build efficient implementation of organizational third steps).doc
- 山地车组装办法(Method for assembling mountain bike).doc
- 山药优质标准化生产周年管理技1(Annual management technique for quality standardization production of Chinese yam 1).doc
- 山建计算机组装与维护 选修课答案- 于宽老师(Answers to optional courses on computer assembly and maintenance).doc
- 1815_1914年欧洲均势关系探析(Analysis of European balance of power in 1815_1914).doc
- 嵌入式填空(Embedded cloze).doc
- 巧借诗词歌赋给宝宝起一个吉祥的名字(Take poetry baby an auspicious name).doc
- 巧克力囊肿不能拖超声引导穿刺法可有效治疗(Chocolate cyst cannot be dragged by ultrasound guided puncture, but it can be treated effectively).doc
- 巧妙面对减肥平台期 解决瘦不下来的困扰(Clever platform to lose weight to solve the problem of thin down).doc
- 嵌入式linux内核编译错误的一些解决办法(Some solutions to compile errors in embedded Linux kernel).doc
- 文件英语(Document English).doc
- 文体学(stylistics).doc
- 文字狱这个营养不良的孩子(The prisoner, the malnourished child).doc
- 我们都可耻地成熟了(We are all shamefully mature).doc
- 数学专业学生必看十部影视(非数学专业的也可以欣赏!!)(Students majoring in mathematics must see ten movies and TV programs (non math majors can also enjoy it!)).doc
- 文学观念的发生——以风为例(六)(叶舒宪)(The emergence of literary ideas -- Taking wind as an example (six) (Ye Shuxian)).doc
- 文艺部迎新生晚会活动总结(Literature and art department welcome freshmen party activities summary).doc
- 无碳小车s型(Carbon free trolley type s).doc
- 日常生活中人体的10个最佳时间(10 best times for the human body in everyday life).doc
- 日常生活的致癌物质(Carcinogens in everyday life).doc
最近下载
- 人教版七年级数学上册第五章一元一次方程.pptx VIP
- 超星学习通网课《从爱因斯坦到霍金的宇宙》尔雅答案2025题目及答案.docx
- 证监会行业分类指引 2012版 (2).xls VIP
- 通信中级整理-终端与业务.pdf VIP
- 【初中数学】第五章一元一次方程单元测试+2024-2025学年人教版数学七年级上册.docx VIP
- 快乐日记(三上日记范文).docx VIP
- 4.1 《喜看稻菽千重浪》课件(共46张PPT)统编版高中语文必修上册.pptx VIP
- 群众安全满意度培训课件.pptx VIP
- 石材厂15万吨年砂石料加工项目突发环境事件应急预案2024年第一版.docx VIP
- 道德与法治人教版二年级上册教案.doc VIP
有哪些信誉好的足球投注网站
文档评论(0)