网站大量收购独家精品文档,联系QQ:2885784924

数据结构上机(Data structure on computer).doc

  1. 1、本文档共15页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据结构上机(Data structure on computer) [network synthesis - self-study examination questions] Weave a C program, it can be read according to the data to construct a directed graph G, and output G DFS traversal sequence (starting from V0), the form of input n V0, Vi0, Vi2, V1, Vi1, V2...... Vi, Vin, -1, -1 (-1, -1) are the input end tags, and the remaining values are =0 and n0. (Note: the executable name of the program must be e3.exe). #include Typedef, enum, {False, True}, Boolean; Int G[100][100]; Int n; Void (CreatG) / * to establish the adjacency matrix of a graph G[][]*/ {int, I, j; Printf (Input the, number, of, the, node:); Scanf (%d, n); Printf (\n); For (i=0; Ifor (j=0); J G[i][j]=0; Do {scanf (%d%d, i, j); G[i][j]=1; }while ((I! =-1) (J! =-1)); } Void (TopSort) / * * / output topological sorting, topological sequence {int, I, j; Int degree[100]; / * in accordance with precursor vertex priority that degree[] storage nodes in.*/ Boolean, visited[100], flag=True; Printf (The Topolgical Order as follow:); For (i=0; i{degree[i]=0; Visited[i]=False; } Printf (\n); While (flag==True) { For (i=0; Ifor (j=0; jdegree[i]=G[j][i]+degree[i]); I=0; While ((IIF (i{printf) (%d), I); Visited[i]=True; For (j=0; J {G[i][j]=0; degree[j]=0;} } Else flag=False; } } (main) {CreatG (); TopSort (); } 1., a C program, which can be read according to the data to construct a directed graph G, and output G adjacency matrix and DFS traversal sequence (starting from V0), the form of input n Vi0, Vj0, Vj2, Vi1, Vj1, Vi2...... Vim, Vjm, -1, -1 (-1, -1 are input end tags), they are all integers, and 100n0, and the rest of the values are =0, and (Note: the executable name of the program must be e1.exe, stored in your account or in its debug directory) 2. compiling a C program, it can read two sets of integers (each integer to -9999 for the end tag number is not greater than 1000), and in order to output both of all integers in the first set of integers and not in the second group of integers (w

您可能关注的文档

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档