65,179
社区成员




#include <iostream>
using namespace std;
struct ArcNode
{
int adjvex;
ArcNode *next;
};
template <typename T>
struct VertexNode
{
T vertex;
ArcNode *firstedge;
};
const int MaxSize=10;
template <class T> //这一句
class ALGraph
{
public:
ALGraph(T a[],int n,int e);
~ALGraph(){}//这一句
private:
VertexNode<T> adjlist[MaxSize];
int vertexNum,arcNum;
};
template <class T> //这一句
ALGraph<T>::ALGraph(T a[],int n,int e) //这一句
{
vertexNum=n;arcNum=e;
int i, j, k;//这一句
for(i=0;i<vertexNum;i++)
{
adjlist[i].vertex = a[i];
adjlist[i].firstedge=NULL;
}
for(k=0;k<arcNum;k++)
{cin>>i>>j;
ArcNode *s=new ArcNode;s->adjvex=j;//这一句
s->next=adjlist[i].firstedge;
adjlist[i].firstedge=s;
}
}
int main()
{
int a[6]={1,2,3,4,5,6};
ALGraph<int> (a,6,5); //这一句
return 0;
}