travel Algrithm. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h> #include <conio.h> struct Path { char pass[25]; //sign passed note. int min_distance; //minmax distance from concurrent note.// int nextcity; //next note from current note. struct Path *next; }; int C[25][25]; int Getmin(struct Path *G[25][25],int i,int num_S,char S[25]); // search G[i][n] linking-node. void Write(int i,int n,char S[25],struct Path *G[25][25],int num_S); // Calculate G[i][num_S] void Travel(int size,int i,int n,char S[25],struct Path *G[25][25],int num_S); // signed V-S node. void Trip(int n,char S[25],struct Path *G[25][25]); // Calculate and output the min_distance. void Printpath(char S[],int path[],struct Path *G[][25],int n); // print the path // S[] is the charater of the node. void main() { int n,i,j; int output[25]; char S[25]; struct Path *G[25][25]; printf("Please enter the number of cities:\n"); // Input the numbers of node scanf("%d",&n); printf("Please enter the matrix:\n"); // Input the maxtric of weight. for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",&C[i][j]); printf("The number of cities is:%d\n",n); for(i=0;i<n;i++) { for(j=0;j<n;j++) printf("%d\t",C[i][j]); printf("\n"); } for(i=0;i<n;i++) S[i]='0'; S[i]='\0'; for(i=0;i<n;i++) { G[i][0]=(struct Path *)malloc(sizeof(struct Path)); strcpy(G[i][0]->pass,S); G[i][0]->min_distance=C[i][0]; G[i][0]->next=NULL; } for(i=0;i<n;i++) for(j=1;j<n;j++) G[i][j]=NULL; Trip(n,S,G); Printpath(S,output,G,n); printf("For the demonstration route:\n"); for(i=0;i<n;i++) printf("%d->",output[i]+1); printf("1\n"); getch(); }




























- 1


- 粉丝: 1
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 互联网年中总结通用【ppt精选模板】.pptx
- 程序设计驱动计算思维能力培养的大学计算机基础课的改革和研究.docx
- 毕业优秀论文(旅游网站建设)张禹.doc
- 单片机控制电动机的方案设计书.doc
- 区块链技术下的供应链融资服务平台的构建.docx
- 置换算法存储管理.doc
- 五综合布线系统设计.ppt
- 浅析我国网络信息安全存在的问题及对策.docx
- 2015年软考网络工程施工师学习笔记(整理版).doc
- 浅析情景模拟式项目管理教学法在《报关实务》课程教学中的应用.doc
- 软考网络工程师测验考试知识问答精华.doc
- 基于Android平台的乡村旅游App系统设计与实现.docx
- STC89C52RC单片机的特点.doc
- MATLAB编程与工程应用——第2章-矩阵及其运算.ppt
- 工业自动化控制中计算机控制技术的应用路径思考.docx
- 第六章-面向对象的程序设计44845.doc


