首页 > 编程语言 > 详细

C++之vector用法

时间:2016-09-16 14:12:27      阅读:235      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!