码迷,mamicode.com
首页 > 编程语言 > 详细

C++之vector用法

时间:2016-09-16 14:12:39      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

1.插入配对

std::vector<pair<int,int> > w;

w.push_back(make_pair<int,int>(f,s) );

cout <<w[i].first << " " << w[i].second <<endl;

 

2.元素去重

std::vector<int> all;

sort(all.begin(), all.end());
std::vector<int>::iterator nown = unique(all.begin(), all.end());
all.erase(nown,all.end());

 

3.排序

sort(all.begin(), all.end());

 

C++之vector用法

标签:

原文地址:http://www.cnblogs.com/huangshiyu13/p/5876351.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!