求助各位高手关于数据结构(C语言版)的问题!不胜感激!!

是关于dijstra最短路径算法的
程序编译没错误但是运行不出来,类似的情况已是第二次出现,但不知为什么
#include<stdio.h>

#define MAX 20
#define INFINITY 1000
#define NULL 0
#define OK 0

typedef int** PathMatrix;
typedef int* ShortPathTable;

typedef struct{
int adj;
int *info;
}ArcCell,AdjMatrix[MAX][MAX];
typedef struct{
char vex[MAX];//图顶点的集合
AdjMatrix arcs;
int vexnum,arcnum;//图的顶点数和弧长数
}MGraph;

int CreateUDN(MGraph &G){//图的数组表示法
int Incinfo,i,j;
printf("please input the vexnum and the arcnum:\n");
G.vexnum=5;
G.arcnum=5;Incinfo=1;//scanf("%d %d %d",&G.vexnum,&G.arcnum,&Incinfo);
for(i=0;i<G.vexnum;i++)
scanf("%c",G.vex[i]);
for(i=0;i<G.vexnum;i++)
for(j=0;j<G.vexnum;j++){
G.arcs[i][j].adj=INFINITY;
G.arcs[i][j].info=NULL;
}
for(i=0;i<G.vexnum;i++){
printf("please put into the node connected with %c:\n",G.vex[i]);
for(j=0;j<G.vexnum;j++){
char v1;
scanf("%c",&v1);
if(v1=='0')
break;
else{
for(int k=0;k<G.vexnum;k++)
if (G.vex[k]==v1)
break;
scanf("%d",&G.arcs[k][i].adj);
if(Incinfo)
scanf("%d",G.arcs[k][i].info);
}
}
}
return OK;
}

void ShorttestPath_DIJ(MGraph G,int v0){//dijkstra算法
int final[MAX],P[MAX][MAX],D[MAX];
int i,v,w;
for(v=0;v<=G.vexnum;v++){//赋初值
final[v]=0;
D[v]=G.arcs[v0][v].adj;
for(w=0;w<=G.vexnum;w++)
P[v][w]=0;
if(D[v]<INFINITY){
P[v][v0]=1;
P[v][v]=1;
}
}
D[v]=0;final[v0]=1;
for(i=1;i<G.vexnum;i++){//开始主循环
int min=INFINITY;
for(w=0;w<=G.vexnum;w++)
if(!final[w])
if(D[w]<min){v=w;min=D[w];}
final[v]=1;
for(w=0;w<=G.vexnum;w++)
if(!final[w]&&(min+G.arcs[v][w].adj<D[w])){
D[w]=min+G.arcs[v][w].adj<D[w];
P[w][v0]=P[v][v0];
P[w][w]=1;
}
}
}

int main()
{
MGraph G;
CreateUDN(G);
ShorttestPath_DIJ(G,3);
return 0;
}

调试结果:Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\kernel32.dll', no matching symbolic information found.
Loaded 'C:\Windows\SysWOW64\KernelBase.dll', no matching symbolic information found.
The thread 0x1780 has exited with code -1073741510 (0xC000013A).
The thread 0x724 has exited with code -1073741510 (0xC000013A).
The program 'H:\数据结构\Debug\dijkstra.exe' has exited with code -1073741510 (0xC000013A).

第1个回答  2012-05-15
这个不知道啊
第2个回答  2012-05-19
wa
相似回答