二维vector容器读取txt坐标
template <class vector>
struct HeadLocation{
vector x;
vector y;
}; vector<HeadLocation<int> > gt_loc_; //二维vector容器 void ReadLocationFromTextFile(const string filename) {
cout << "Opening file " << filename << endl;
ifstream infile(filename.c_str());
if (!infile){ printf("不存在此文本文件!"); };
int num_crowd;
infile >> num_crowd;
if (num_crowd <= 0){ cout << "Number of crowd must be positive!\n"; };
gt_loc_.clear(); //size = 0, capicity =?
gt_loc_.resize(num_crowd); //size = num_crowd(行) for (int i = 0; i < num_crowd; i++) {
/*HeadLocation<float> location_t;
HeadLocation<int> location(location_t.begin(), location_t.end());*/
HeadLocation<int> location;
infile >> location.x >> location.y; for (int j = 0; j < 3; ++j) {
location.x = (location.x - 1) / 2;
location.y = (location.y - 1) / 2;
}
gt_loc_[i] = location;
}
infile.close(); // 关闭文件
}
二维vector容器读取txt坐标的更多相关文章
- 动态创建二维vector数组 C和C++ 及指针与引用的区别
二维vectorvector<vector <int> > ivec(m ,vector<int>(n)); //m*n的二维vector 动态创建m*n的二 ...
- C++-二维vector初始化大小方法-备忘
来源: C++——二维vector初始化大小方法 1.直接用初始化方法 名字为vec,大小为n*m,初始值为0的二维vector. vector<vector<)); 2.用resize( ...
- 二维vector基本使用
变量声明 vector<vector<int> > 变量名: 添加行 vector<vector<int> > v2d; for(int i=0;i&l ...
- 二维vector的使用
和数组一样,数组有二维的数组,vector也有二维的vector.下面就介绍一下二维vector的使用方法. 一般声明初始化二维vector有三种方法 (1) vector< vector< ...
- C#读txt文件并写入二维数组中(txt数据行,列未知)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
- STL学习二:Vector容器
1.Vector容器简介 vector是将元素置于一个动态数组中加以管理的容器. vector可以随机存取元素(支持索引值直接存取, 用[]操作符或at()方法,这个等下会详讲). vector尾部添 ...
- STL学习系列二:Vector容器
1.Vector容器简介 vector是将元素置于一个动态数组中加以管理的容器. vector可以随机存取元素(支持索引值直接存取, 用[]操作符或at()方法,这个等下会详讲). vector尾部添 ...
- java生成二维码以及读取案例
今天有时间把二维码这块看了一下,方法有几种,我只是简单的看了一下 google 的 zxing! 很简单的一个,比较适合刚刚学习java的小伙伴哦!也比较适合以前没有接触过和感兴趣的的小伙伴,o ...
- C++STL二维vector指定位置排序
自己一直用vector 二维的存储变量 有时候需要进行排序 在此 为记录一下方法 废话少说直接上代码 #include <QCoreApplication> #include <io ...
随机推荐
- wireshark抓取qq数据包
抓包接口设置成本地连接 点击start,登录qq,输入oicq进行过滤qq包 找到第一个OICQ,点击后,点击oicq-IM software 可以看到自己登录的QQ号码为765343409 本机IP ...
- jquery延时刷新
setTimeout(function(){ location.replace(location.href); },1000);
- New for ASP.NET Web Pages: Conditional attributes
from:http://www.mikepope.com/blog/AddComment.aspx?blogid=2353 March 01, 2012 The beta release of ASP ...
- [LintCode笔记了解一下]39.恢复旋转排序数组
思路: 1.需要O(n)的事件复杂度,所以多次循环不考虑 2.四步翻转法 -第一步,找到数组里最小的那个数字,因为是旋转排序数组,所以只要找到某个位置arr[i]>arr[i+1]的话,就找到了 ...
- LibreOJ 6003 魔术球 (最大流)
题解:每次加入两个点,对于和为平方数的两个值所对应的点建边,反正网络流可以跑残量网络,所以就没有什么关系了…… 代码如下: #include<cmath> #include<queu ...
- Linux下抓包命令tcpdump
本文内容来源于网络 PS:tcpdump是一个用于截取网络分组,并输出分组内容的工具,简单说就是数据包抓包工具.tcpdump凭借强大的功能和灵活的截取策略,使其成为Linux系统下用于网络分析和问题 ...
- C# 密封(2)
上一章节说到 sealed 作用于类,那么sealed 作用到方法和成员上面该如何呢. 在C# 中 Sealed作用于方法必须是重写之后的方法.也就是override+sealed.在之后别的类在继 ...
- Google的C++代码规范
英文版:http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml 中文版:http://zh-google-styleguide ...
- linux系统安全及应用——弱口令检测
Joth the Ripper,简称JR,一款密码分析工具,支持字典式的暴力破解,通过对shadow文件的口令分析,可以检测密码强度,官方网站http://www.openwall.com/john/ ...
- underscore里面的debounce与throttle
throttle 策略的电梯.保证如果电梯第一个人进来后,15秒后准时运送一次,不等待.如果没有人,则待机. debounce 策略的电梯.如果电梯里有人进来,等待15秒.如果又人进来,15秒等待重新 ...