程序运行结果正确,但在运行完后,会出现一个发送错误的对话框,不知为什么???
#include<stdio.h>
#include<stdlib.h>
#define maxsize 10
typedef struct Pnode
{
int num;
char data;
struct Pnode *next;
}*pnode;
struct Hnode
{
char data;
pnode next;
};
void creatgraph( int *v );
void disgraph ( int v );
void depthsearch( int x, int *visited );
struct Hnode head[maxsize];
void main( void )
{
int v, visited[maxsize]={0};
creatgraph( &v );
disgraph( v );
depthsearch(1,visited);
}
void creatgraph( int *v )
{
int i, s, f, e;
pnode p, q;
printf("请输入 v and e: ");
scanf("%d%d",v,&e);
getchar();
for( i=1; i <= *v; i++ )
{
printf("请输入第 %d 个顶点信息 ",i);
scanf("%c",&head[i].data);
getchar();
head[i].next=NULL;
}
for( i=1; i <= e; i++ )
{
printf("请输入第 %d 条边起点号和终点号 ",i);
scanf("%d%d",&s,&f);
getchar();
p=(pnode)malloc(sizeof(struct Pnode));
q=(pnode)malloc(sizeof(struct Pnode));
p->data=head[s].data;
p->num=s;
q->data=head[f].data;
q->num=f;
p->next=head[f].next;
head[f].next=p;
q->next=head[s].next;
head[s].next=q;
}
q=NULL; p=NULL;
}
void disgraph( int v )
{
int k;
pnode p;
for( k=1; k <= v; k++ )
{
printf(" [%d,%c] =>",k,head[k].data);
p=head[k].next;
while( p != NULL )
{
printf(" (%d,%c) ->",p->num,p->data);
p=p->next;
}
printf(" ^ \n");
}
p=NULL;
}
void depthsearch( int x, int *visited )
{
if( visited[x] == 1 ) exit(0);
pnode p=NULL;
printf(" [%d,%c] =>",x,head[x].data);
visited[x]=1;
p = head[x].next;
while( visited[p->num] == 1 && p != NULL )
p = p->next;
depthsearch( p->num,visited );
p = NULL;
}