看下下面的程序哪出错了 大家帮忙看看,谢谢了
#include "Stdio.h"
#include "Conio.h"
#define MAX 30
#define MAX_VERTEX_NUM 20
#define INT_MAX 20000
typedef struct
{
char vex[MAX];
int arc[MAX][MAX];
int vexnum,arcnum;
}MGraphy;
CreateMGraphy(MGraphy *G)
{
int i=0,j=0,k=0;
char v1,v2;
printf("Please input vexnum and arcnum:\n");
scanf("%d",&(G->vexnum));
scanf("%d",&(G->arcnum));
printf("Please input vex value:");
for (i=0;i<G->vexnum;i++)
{
scanf("\n%c",&(G->vex[i]));
printf("%c ",G->vex[i]);
}
for (i=0;i<G->vexnum;i++)
for (j=0;j<G->vexnum;j++)
G->arc[i][j]=0; /*弧的初始化*/
for (k=0;k<G->arcnum;k++)
{
printf("Please input two letters:\n");
scanf("%c\n",&v1);
scanf("%c\n",&v2);
printf("v1=[%c] v2=[%c]\n",v1,v2); /*在这里输出就出错了*/
i=LocateVex(G,v1);
j=LocateVex(G,v2); /*确定已有的顶点的位置*/
printf("i=[%d] j=[%d]\n",i,j); /*这里输出时也出错了*/
G->arc[i][j]=G->arc[j][i]=1; /*已确定的弧标记为1*/
}
for (i=0;i<G->vexnum;i++)
{ /*打印出弧关系矩阵*/
for (j=0;j<G->vexnum;j++)
printf("%d ",G->arc[i][j]);
printf("\n");
}
}
int LocateVex(MGraphy *G,char v)
{
int i;
for (i=0;i<G->vexnum;i++)
if ((int)G->vex[i]==(int)v)
{
return i;
}
return 0;
}
int main(void)
{
MGraphy *G;
G=(MGraphy *)malloc(sizeof(MGraphy));
CreateMGraphy(G);
getch();
return 0;
}