数据结构课程设计报告《图的遍历》(14)
发布时间:2021-06-05
发布时间:2021-06-05
}
}
}
}
main()
{
int n;
Graph *g=(Graph *)malloc(sizeof(Graph));
char menu;
printf("Please input the number of vertex:\n");
scanf("%d",&n);
creatgraph(g,n);
printf("This is the linjiejuzhen of graph:\n");
printgraph(g);
input:
printf("Please input b or d or q ,Breadth_first: b Depth_first: d quit: q\n"); while((menu=getchar())=='\n');
if(menu=='b')
{
printf("Breadth_first:\n");
BESTraverse(g);
printf("\n");
goto input;
}
else if(menu=='d')
{
printf("Depth_first:\n");
dfstraverse(g);
printf("\n");
goto input;
}
else if(menu=='q')
{
exit(0);
}
else
{
printf("Input error!Please input b or d!\n");
}
}
上一篇:面向对象课程设计参考题目