64,649
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
using namespace std;
template <class T>
class SortBySelf
{
public:
bool operator () ( const T& a, const T& b)
{
return a > b;
}
};
void PrintInt( int& input)
{
if( input % 2 == 0)
{
input++;
}
}
void PrintSet( int& a )
{
cout<< a ;
}
int main(void)
{
set<int, SortBySelf<int>> s ;
for(int i = 0 ; i < 10; i++)
s.insert(i);
for_each( s.begin(), s.end(), PrintInt);
for_each(s.begin(), s.end(), PrintSet);
for( set<int, SortBySelf<int>>::iterator it = s.begin(); it != s.end(); it++ )
cout<< *it <<" ";
return 0 ;
}
你偷偷摸摸的改,谁知道你改了.