STL中的vector实现邻接表
- /*
- STL中的vector实现邻接表
- 2014-4-2 08:28:45
- */
- #include <iostream>
- #include <vector>
- #include <cstdlib>
- #define MAX 10000
- using namespace std;
- struct EdgeNode{ //边表节点类型
- int to, w; //顶点序号和边长
- };
- vector<EdgeNode> map[MAX];
- int main(){
- EdgeNode e;
- int n, m, i, j, k, w;
- cin >> n >> m; //n个顶点m组数据
- for(i = 0; i < m; ++i){
- cin >> j >> k >> w;
- e.to = k; e.w = w;
- map[j].push_back(e);
- }
- //遍历
- for(i = 1; i <= n; ++i){
- for(vector<EdgeNode>:: iterator k = map[i].begin();
- k != map[i].end(); ++k){
- EdgeNode t = *k;
- cout << i << ' ' << t.to << ' ' << t.w << endl;
- }
- }
- system("pause");
- return 0;
- }
STL中的vector实现邻接表的更多相关文章
- 利用C++ STL的vector模拟邻接表的代码
关于vector的介绍请看 https://www.cnblogs.com/zsq1993/p/5929806.html https://zh.cppreference.com/w/cpp/conta ...
- 转:用STL中的vector动态开辟二维数组
用STL中的vector动态开辟二维数组 源代码:#include <iostream>#include <vector>using namespace std;int mai ...
- STL中的Vector相关用法
STL中的Vector相关用法 标准库vector类型使用需要的头文件:#include <vector>. vector 是一个类模板,不是一种数据类型,vector<int> ...
- (转)C++ STL中的vector的内存分配与释放
C++ STL中的vector的内存分配与释放http://www.cnblogs.com/biyeymyhjob/archive/2012/09/12/2674004.html 1.vector的内 ...
- C++STL中的vector的简单实用
[原创] 使用C++STL中的vector, #include <stdio.h> #include<stdlib.h> #include<vector> usin ...
- HDU 2647 Reward(拓扑排序,vector实现邻接表)
Reward Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- STL中的vector 和list
参考书目:visual c++ 入门经典 第七版 Ivor Horton著 第十章 认识两个容器:vector和list 容器:是STL(Standard Template Library 标准模板库 ...
- stl 中List vector deque区别
stl提供了三个最基本的容器:vector,list,deque. vector和built-in数组类似,它拥有一段连续的内存空间,并且起始地址不变,因此 它能非常好的支持随 ...
- c++ STL中的vector与list为什么没有提供find操作?
map里有,set里也有,vector,list没有,太不公平了吧. 其实应该考虑为什么map,set里有find操作. include<algorithm>里有通用的find操作,通用的 ...
随机推荐
- caffe训练自己的图片进行分类预测--windows平台
caffe训练自己的图片进行分类预测 标签: caffe预测 2017-03-08 21:17 273人阅读 评论(0) 收藏 举报 分类: caffe之旅(4) 版权声明:本文为博主原创文章,未 ...
- 自己定义ActionBar标题与菜单中的文字样式
自己定义标题文字样式 标题样式是ActionBar样式的一部分,所以要先定义ActionBar的样式 <style name="AppTheme" parent=" ...
- Jquery放大镜插件---imgzoom.js(原创)
Jquery放大镜插件imgzoom能够实现图片放大的功能,便于与原图进行比较. 使用方法: 1.引入jQuery与imgzoom,imgzoom.css <link rel="sty ...
- Mvc创建并注册防盗链
创建CustomHandler.JpgHandler public class JpgHandler : IHttpHandler { public void ProcessRequest(HttpC ...
- Graphics and Animation in iOS
using System;using UIKit;using CoreGraphics;using Foundation; namespace GraphicsAnimation{ public c ...
- 2018-11-9-匿名函数&递归函数初识
1.匿名函数(lambda) 2.递归函数初识
- Use Apache HBase™ when you need random, realtime read/write access to your Big Data.
Apache HBase™ is the Hadoop database, a distributed, scalable, big data store. Use Apache HBase™ whe ...
- please add a 'mainClass’ property
when build an spring project with this command: mvn spring-boot:run there will may show an error mes ...
- java创建文件夹以及文件
java在创建文件的过程中如果改文件的路径不存在: 会出现下面这种情况 java.io.IOException: 系统找不到指定的路径. at java.io.WinNTFileSystem.crea ...
- UI 自动化测试工具BackstopJS简介(1)
BackstopJS源码地址 https://github.com/garris/BackstopJS 我写了一个DEMO放到github上面,https://github.com/shenggen1 ...