博客
关于我
链式前向星(待更新)
阅读量:319 次
发布时间:2019-03-04

本文共 580 字,大约阅读时间需要 1 分钟。

#include
using namespace std;const int maxn = 1005;//点的最大个数 int n,m,cnt;struct Edge{ int to,w,next;}edge[maxn];int head[maxn];//以i为起点的最后一条边的边的编号 void init(){ for(int i=0;i<=n;i++) head[i] = -1; } void add(int u,int v,int w){ edge[cnt].to = v; edge[cnt].w = w; edge[cnt].next = head[u]; head[u] = cnt++;//编号数加一 }int main(){ cin>>n>>m; int u,v,w; init(); for(int i=1;i<=m;i++) { cin>>u>>v>>w; add(u,v,w); } //遍历 for(int i=1;i<=n;i++) { //n个起点 for(int j=head[i];j!=-1;j = edge[j].next) { cout<
<<" "<
<<'\n'; } } return 0;}

转载地址:http://nirq.baihongyu.com/

你可能感兴趣的文章
mysql CPU使用率过高的一次处理经历
查看>>
Multisim中555定时器使用技巧
查看>>
MySQL CRUD 数据表基础操作实战
查看>>
multisim变压器反馈式_穿过隔离栅供电:认识隔离式直流/ 直流偏置电源
查看>>
mysql csv import meets charset
查看>>
multivariate_normal TypeError: ufunc ‘add‘ output (typecode ‘O‘) could not be coerced to provided……
查看>>
MySQL DBA 数据库优化策略
查看>>
multi_index_container
查看>>
mutiplemap 总结
查看>>
MySQL Error Handling in Stored Procedures---转载
查看>>
MVC 区域功能
查看>>
MySQL FEDERATED 提示
查看>>
mysql generic安装_MySQL 5.6 Generic Binary安装与配置_MySQL
查看>>
Mysql group by
查看>>
MySQL I 有福啦,窗口函数大大提高了取数的效率!
查看>>
mysql id自动增长 初始值 Mysql重置auto_increment初始值
查看>>
MySQL in 太多过慢的 3 种解决方案
查看>>
Mysql Innodb 锁机制
查看>>
MySQL InnoDB中意向锁的作用及原理探
查看>>
MySQL InnoDB事务隔离级别与锁机制深入解析
查看>>