马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
# include <stdio.h>
# include <stdlib.h>
#define MAXVEX 20
#define NON -1
typedef char VexType;
typedef float AdjType;
typedef int Status;
typedef struct
{
int vexnum,arcnum;
VexType vex[MAXVEX];
AdjType arc[MAXVEX][MAXVEX];
}GraphMatrix;
int LocateVex(GraphMatrix *pgraph, VexType v)
{
int k;
for (k=0;k<pgraph->vexnum;k++)
if(v==pgraph->vex[k]) return k;
return NON;
}
Status CreateUDN((GraphMatrix &g)
{
Adjtype w;
VexType v1,v2;
int i,j,m,n;
printf("input the vexnum:"); scanf("%d",&g.vexnum);
printf("input the arcnum:"); scanf("%d",&g.arcnum);
for(i=0;i<g.vexnum;i++)
{
printf("input the vex[%d]:",i);
scanf("%c",&g.vex[i]);
}
for(i=0;i<g.vexnum;i++)
for(j=0;j<g.vexnum;j++)
{
g.arc[i][j]=INFINITY;
}
for(j=0;j<g.arcnum;j++)
{
printf("input v1:");scanf("%c",&v1);
printf("input v2:");scanf("%c",&v2);
printf("input w:"); scanf("%d",&w);
m=LocateVex(&g,v1);
n=LocateVex(&g,v2);
g.arc[m][n]=w;
g.arc[n][m]=g.arc[m][n];
}
return OK;
}
main()
{
GraphMatrix g;
CreateUDN(&g);
}
出现这些错误,求大神!
D:\Users\narutoxyl\新建文件夹 (2)\邻接矩阵.c(48) : error C2143: syntax error : missing ')' before '('
D:\Users\narutoxyl\新建文件夹 (2)\邻接矩阵.c(48) : error C2143: syntax error : missing ')' before '&'
D:\Users\narutoxyl\新建文件夹 (2)\邻接矩阵.c(48) : error C2091: function returns function
D:\Users\narutoxyl\新建文件夹 (2)\邻接矩阵.c(48) : error C2143: syntax error : missing '{' before '&'
D:\Users\narutoxyl\新建文件夹 (2)\邻接矩阵.c(48) : error C2059: syntax error : '&'
D:\Users\narutoxyl\新建文件夹 (2)\邻接矩阵.c(48) : error C2059: syntax error : ')'
D:\Users\narutoxyl\新建文件夹 (2)\邻接矩阵.c(84) : warning C4013: 'CreateUDN' undefined; assuming extern returning int |