資源簡介
針對一按照鄰接表存放的有向圖,計算圖中節(jié)點(diǎn)的出度和入度.
代碼片段和文件信息
#include
#include
#include
using?namespace?std;
typedef?struct?MGraph
{
char?Vex[20];
int?Arcs[20][20];
int?VexnumArcnum;
}MGraph;
int?Find(MGraph?&Gchar?c)
{
for(int?i?=?0;i? if(G.Vex[i]?==?c)??return?i;
return?0;
}
void?Creat(MGraph?&G)
{
for(int?i?=?0;i for(int?j?=?0;j {
G.Arcs[i][j]?=?0;
}
for(int?k?=?0;k {
char?c1c2;
int?ij;
cin>>c1>>c2;
i?=?Find(Gc1);?j?=?Find(Gc2);
G.Arcs[i][j]?=?1;??
//?G.Arcs[j][i]?=?1;??
}
/
評論
共有 條評論