谁有空帮我看下这程序
我们数据结构的作业 就是图的遍历 编的这程序运行时候报错 怎么检查也不知道哪错了 脑袋发懵了 谁帮忙看下#include<iostream>
using namespace std;
#define max 100
typedef struct{
char vexs[max];
int edges[max][max];
int vnum,snum;
}MGraph;
int visited[max];
void Creatmgraph(MGraph *G){
int i,j,k;
cout<<"请输入顶点数和边数(输入格式为:顶点数 边数):"<<endl;
cin>>G->vnum>>G->snum;
cout<<"请输入顶点信息(输入格式为:顶点号<CR>):"<<endl;
for(i=1;i<=G->vnum;i++)
cin>>G->vexs[i];
for(i=1;i<=G->vnum;i++)
for(j=1;j<=G->vnum;j++)
G->edges[i][j]=0;
cout<<"请输入每条边对应的两个顶点的序号(序号从1起,输入格式:i j(用空格分开))"<<endl;
for(k=1;k<=G->snum;k++){
cin>>i>>j;
G->edges[i][j]=1;
G->edges[j][i]=1;
}
}
void Showgraph(MGraph *G){
int i,j;
MGraph *g;
g=G;
cout<<"图的邻接矩阵为:"<<endl;
for(i=1;i<=g->vnum;i++){
for(j=1;j<=g->vnum;j++)
cout<<g->edges[i][j];
cout<<endl;
}
}
int fisradjvex(MGraph *G,int v){
int j;
for(j=1;j<=G->vnum;j++){
if(G->edges[v][j]) break;
}
if(G->edges[v][j]) return j;
else return 0;
}
int nextadjvex(MGraph *G,int v,int w){
int j;
for(j=w+1;j<=G->vnum;j++){
if(G->edges[v][j]) break;
}
if(G->edges[v][j]) return j;
else return 0;
}
void init_visited(){
int i;
for(i=0;i<=max;i++)
visited[i]=0;
}
void dfs(MGraph *G,int v){
int w;
visited[v]=1;
cout<<G->vexs[v]<<endl;
for(w=fisradjvex(G,v);w;w=nextadjvex(G,v,w))
if(!visited[w])
dfs(G,w);
}
void main(){
int x;
MGraph H;
Creatmgraph(&H);
Showgraph(&H);
init_visited();
cout<<"从哪点开始遍历:(输入点的序号)"<<endl;
cin>>x;
dfs(&H,x);
}