求邻接表的代码/kk
没有指针,只有一个变量名
by zhy137036 @ 2021-01-23 18:09:00
对比链式前向星:
```cpp
int cnt,to[2*N],nxt[2*N],head[2*N];
//定义(四个变量和数组)
int u,v; cin>>u>>v;
to[++cnt]=v;
nxt[cnt]=head[u];
head[u]=++cnt;
//输入(多两行)
for(int i=head[u];i;i=nxt[i])
//遍历(差不多)
```
by zhy137036 @ 2021-01-23 18:15:18
上一页 |