图的初始化问题
scanf("%d %d",&H->vex_num,&H->arc_num);printf("vex No. %d;arc No. %d\nInput the vex order\n",H->vex_num,H->arc_num);
for(i=0;i<H->vex_num;i++)
scanf("%d",&H->vexs[i]);
printf("Input the arc's vertex\n");
for(k=0;k<H->arc_num;k++)
{scanf("%d %d",&i,&j);
if(i==j) { printf("\ntwo useless vertex's\nInput the arc's vertex\n"); k--; continue; }
else
{for(k=0;k<H->arc_num;k++)
if(H->vexs[k]==i) { i=k; F++; }
else if(H->vexs[k]==j) { j=k; F++; }
if(F>=2) { printf("The vertexs didn't exit\n"); F=0; k--; continue; }
if(H->arcs[j][i]==1)
printf("\nThat arcs has exist!\n");
else
{H->arcs[i][j]=H->arcs[j][i]=1;
Deg[i]++;
Deg[j]++;
}
F=0;
}
}
当输入弧是不同的节点号i,j时,程序跑出:The vertexs didn't exit。即F++没有成功执行;而且重复两次后即跳出了for循环。始终没有看的问题所在,大虾们帮忙修改!