邻接表用数组来实现。采用头插法。
#include <iostream>
using namespace std;
const int H = 10;
int main()
{
int u[H*2],v[H*2],w[H*2];
int first[H];//first[i]表示i号节点的第一条边
int next[H*2];//next[i]表示第i条边的下一条边
int n,m;//n个节点,m条边
cin>>n>>
邻接表用数组来实现。采用头插法。
#include <iostream>
using namespace std;
const int H = 10;
int main()
{
int u[H*2],v[H*2],w[H*2];
int first[H];//first[i]表示i号节点的第一条边
int next[H*2];//next[i]表示第i条边的下一条边
int n,m;//n个节点,m条边
cin>>n>>