for(t=0;t
FindCircle(path[t][0],path[t][0],num,path[t][0]);
if(circle)
{/*if a circle exsits,roll back*/
circle=0;
i--;
exsit=0;
touched[v1][v2]=0;
touched[v2][v1]=0;
min=maxright;
}
else
{
record++;
min=maxright;
}
}
}
if(!status)
printf("We cannot deal with it because the graph is not connected!\n");
else
{
for(i=0;i
printf("Path %d:vertex %d to vertex %d\n",i+1,path[0]+1,path[1]+1);
}
return 1;
}
int FindCircle(int start,int begin,int times,int pre)
{ /* to judge whether a circle is produced*/
int i;
for(i=0;i
if(touched[begin]==1)
{
if(i==start&&pre!=start)
{
circle=1;
return 1;
break;
}
else
if(pre!=i)
FindCircle(start,i,times,begin);
else
continue;
}
return 1;
}
相關(guān)推薦:
2011計(jì)算機(jī)等級(jí)二級(jí)C語(yǔ)言五套模擬試題及答案
計(jì)算機(jī)等級(jí)考試二級(jí)C語(yǔ)言歷年真題匯總(2005-2010)
2011年計(jì)算機(jī)等級(jí)考試二級(jí)C語(yǔ)言常見(jiàn)問(wèn)題匯總
計(jì)算機(jī)等級(jí)考試二級(jí)C語(yǔ)言常見(jiàn)知識(shí)點(diǎn)總結(jié)