链式前向星
来源:互联网 发布:搜索电影免费网络观看 编辑:程序博客网 时间:2024/05/12 18:46
#include<cstdio>
#include<cstdlib>
#include<cstring>#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1000;
const int maxm=100;
int to[maxm],next[maxm],begin[maxm],p[maxm],w[maxm],e;
void add(int x,int y,int z){
to[++e]=y;
next[e]=begin[x];
begin[x]=e;
w[e]=z;
}
void dfs(int x){
for(int i=begin[x];i;i=next[i])
if(!p[to[i]])
dfs(to[i]);
}
int main(){
int i,j,k,m,n;
scanf("%d%d",&n,&m);
for(i=1;i<=m;i++){
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
add(x,y,z);
add(y,x,z);
}
dfs(1);
return 0;
}
1 0
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- 链式前向星
- Android JNI知识简介
- PHP网页的工作原理
- 程序流程控制
- 260. Single Number III
- iPhone OS主要提供以下几种播放音频的方法
- 链式前向星
- 观察者模式(行为型)
- android:属性
- Android学习笔记(七*侧滑切换图片)
- Android JNI(实现自己的JNI_OnLoad函数)
- HDU 5531 Rebuild(三分)
- Android 四大组件和五大布局
- 转载-TCP协议实现原理
- 关于OkHttp框架的使用方法