标题:[分享]partition() 实在无聊之举~
取消只看楼主
三少爷
Rank: 1
等 级:新手上路
帖 子:192
专家分:0
注 册:2004-4-29
 问题点数:0 回复次数:1 
[分享]partition() 实在无聊之举~

#include <vector> #include <algorithm> #include <iostream>

bool greater5 ( int value ) { return value >5; }

int main( ) { using namespace std; vector <int> v1, v2; vector <int>::iterator Iter1; int i; for ( i = 0 ; i <= 10 ; i++ ) { v1.push_back( i ); } random_shuffle( v1.begin( ), v1.end( ) ); cout << "Vector v1 is ( " ; for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ ) cout << *Iter1 << " "; cout << ")." << endl; // Partition the range with predicate greater5 partition ( v1.begin( ), v1.end( ), greater5 ); cout << "The partitioned set of elements in v1 is: ( " ; for ( Iter1 = v1.begin( ) ; Iter1 != v1.end( ) ; Iter1++ ) cout << *Iter1 << " "; cout << ")." << endl; return 0; }

//小菜给大家(主要给刚入门的)看看,不运行,能说说运行结果(大致)

[此贴子已经被作者于2004-11-12 22:21:47编辑过]

搜索更多相关主题的帖子: partition 分享 
2004-11-12 22:20
三少爷
Rank: 1
等 级:新手上路
帖 子:192
专家分:0
注 册:2004-4-29
得分:0 

呵呵~看过也算达到目的了


2004-11-12 22:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-7560-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.081589 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved