/* template<class _FwdIt> _FwdIt unique(_FwdIt _First, _FwdIt _Last) template<class _FwdIt, class _Pr> inline _FwdIt unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred) */ #include <algorithm> #include <iostream> using namespace std; int main() { int a[10]; //ソートされている必要は無い //ソートされていた場合は重複する全ての要素が消える for( int i = 1, j = 0; i <= 4; ++i ) for( int k = 0; k < i; ++k ) a[j++] = i; // 1,2,2,3,3,3,4,4,4,4, copy( a,a+10, ostream_iterator<int>(cout,",") ); cout << endl; // 1,2,3,4, copy( a,unique(a,a+10), ostream_iterator<int>(cout,",") ); cout << endl; return 0; }
atwikiでよく見られているWikiのランキングです。新しい情報を発見してみよう!
最近アクセスの多かったページランキングです。話題のページを見に行こう!