为什么for循环结束程序就终止了
Status CreateALGraph(ALGraph *G) (构造图){
int i,semester_num,v,w,vew;
printf ( "请输入学期数目:" );
scanf ( "%d",&semester_num );
if ( semester_num > 8 )
{
printf ( " 请重新输入学期数目:" );
scanf ( "%d" , &semester_num );
}
printf ( " 请输入课程数目 (课程数必须小于40):" );
scanf ( "%d" , &vew );
if ( vew > = 40 )
{
printf ( "请重新输入课程数,数目小于40:" );
scanf( "%d" , &vew );
}
G->vexnum = vew;
for ( i=0 ; i<G->vexnum ; i++ )
{
printf ( " 请输入%d课程的名字:\n ",i+1 );
getchar ();
scanf ( "%s" , &G->vertices[i].data );
getchar();
G->vertices[i].firstarc=NULL;
}
printf ( " 请输入课程间的先后关系(总边数):" );
scanf ( "%d" , &G->arcnum );
for ( i=0 ; i<G->arcnum ; i++ )
{
printf ( " 请输入课程间两两的先后关系(用整数表示,整数整数之间用逗号隔开):" );
scanf ( "%d ,%d" , &v, &w );
ArcNode *p;
p = (ArcNode*) malloc (sizeof(ArcNode));
if(!p) return 0;
p->adjvex = w-1;
p->nextarc = G->vertices[v-1].firstarc;
G->vertices[v-1].firstarc = p;
}
return 1;
}
[此贴子已经被作者于2017-2-20 21:43编辑过]