首页 > 其他 > 详细

链式前向星模板

时间:2017-08-22 19:34:21      阅读:340      评论:0      收藏:0      [点我收藏+]

整理一下,按边存储的结构都可以用此存储。

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<cstdlib>
 5 #include<iostream>
 6 #include<cmath>
 7 using namespace std;
 8 typedef long long ll;
 9 const int maxn=1e5+3;
10 struct Edge{
11     int nxt;
12     int to;
13     int w;
14 }e[maxn];
15 int head[maxn],cnt;
16 void add_edge(int u,int v,int w){//单向
17     e[cnt].w=w;
18     e[cnt].to=v;
19     e[cnt].nxt=head[u];
20     head[u]=cnt++;
21 }
22 int main(){
23     int u=1;
24     for(int i=head[u];i!=-1;i=e[i].nxt){
25         
26     }
27 }

 

链式前向星模板

原文:http://www.cnblogs.com/elpsycongroo/p/7413180.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!