(compiled form are not wrong, perform when there is some garbled! For help,)
#include
using namespace std;
Const int MaxSize=4;
The class MGraph
{
Public:
MGraph (char [], int n, int e);
Void DFSTraverse (int v);
Private:
Char vertex [MaxSize];
Int the arc [MaxSize] [MaxSize];
Int vertexNum arcNum;
};
MGraph: : MGraph (char [], int n, int e)
{
VertexNum=n; ArcNum=e;
int i,j,k;
For (I=0; i
for(i=0; i
For (k=0; K
Cin> i> j;
The arc [I] [j]=1;
The arc [j] [I]=1;
}
}
Void MGraph: : DFSTraverse (int v)
{int I, j;
Int visited [MaxSize]={0};
for(i=0; i
Cout<& lt; Vertex [v];
Visited [v]=1;
for(j=0; J
}
Int main ()
{char q [4]={' a ', 'b', 'c', 'd'};
Int w, I;
/* cout<" Please input data: "& lt; & lt; Endl;
for(i=0; i<4. I++)
{
Cin> w;
Q [I]=w;
} */
MGraph s (q, 4, 4);
Spyware doctor FSTraverse (0);
//return 0;
}
CodePudding user response:
The infinite loop? Visited the array should be publicCodePudding user response:
Sorry, I don't understand, can say a little detail, I am more stupid,, come onCodePudding user response:
What are your results?