链式前向星(图)
来源:互联网 发布:java定义方法 编辑:程序博客网 时间:2024/06/06 16:47
#include <iostream>#include <cstring>using namespace std;const int M=1005;int head[M];struct node{ int to; int w; int next;}Node[M];int main(){ int n,m; cin>>n>>m; memset(head,-1,sizeof(head)); for(int i=1;i<=m;i++) { int a,b,w; cin>>a>>b>>w; Node[i].to=b; Node[i].w=w; Node[i].next=head[a]; head[a]=i; } for(int i=1;i<=n;i++) { for(int k=head[i];k!=-1;k=Node[k].next) cout<<i<<" "<<Node[k].to<<" "<<Node[k].w<<endl; } return 0;}/*8 125 8 296 1 128 3 111 2 43 1 224 3 177 4 256 5 98 7 71 6 93 2 196 7 41 6 91 2 43 2 193 1 224 3 175 8 296 7 46 5 96 1 127 4 258 7 78 3 11*/
0 0
- 链式前向星(图)
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- HMM 隐式马尔科夫模型
- 蓝桥杯 算法设计_2 特殊回文数
- UML建模中的类间关系(C++)--设计模式
- *bzoj1260 [CQOI2007] 涂色paint 题解
- linux find 批量删除
- 链式前向星(图)
- oracle存储过程里嵌套游标循环
- (libgdx小结)window(游戏对话框的使用)
- Geeks 面试题: Ugly Numbers
- VMware中RedHat图形界面与命令介面的快速切换
- shell学习之按照某列合并两个文件
- Linux ALSA声卡驱动之一:ALSA架构简介
- @@errow用法
- Eclipse SDK配置