C++相談室 part54
■ このスレッドは過去ログ倉庫に格納されています
0118デフォルトの名無しさん
2006/11/02(木) 19:50:31#include <list>
#include <functional>
#include <iostream>
using namespace std;
template<class InputIterator> void Display(InputIterator first, InputIterator last){
for(InputIterator i = first; i != last; i++)cout << *i << " ";
}
template<class T> struct MyGreater : public binary_function<const T, const T, bool> {
bool operator() (const T &t1, const T &t2) const { return t1 > t2;}
};
void main(){
int a[8] = {5,8,4,2,41,6,9,7};
int b[14] = {9,9,4,2,1,0,5,6,7,1,1,1,1,1};
list<int> lst1(&(a[0]), &(a[7]) + 1);
list<int> lst2(&(b[0]), &(b[13]) + 1);
list<int>::iterator w = lst1.begin();
advance(w, 3); lst1.splice(w, lst2);
Display(lst1.begin(), lst1.end());//3
lst1.sort(); Display(lst1.begin(), lst1.end());//4
lst1.sort(not2(greater<int>() ) );//-------ココです
Display(lst1.begin(), lst1.end());//5
}
■ このスレッドは過去ログ倉庫に格納されています