Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
#include <iostream>
#include 
<algorithm>

using namespace std;

template
<class I,class F>
get(I from,I to,F f)
{
    I ret 
= to;
    std::sort(from,to,f);
    
while(from != to)
    {
        
if(*from != *(from+1))
        {
            ret 
= from+1;
            
break;
        }
        from 
++;
    }
    
return ret;
}

template
<class T>
bool isLessThen(T a,T b)
{
    
return a < b;
}

int main()
{
    
int arr[] = {2,3,4,5,8,2,9};
    
int* itr = get(arr,arr+7,isLessThen<int>);
    cout 
<<*itr<< endl;
    
return 0;
}
posted on 2017-03-26 09:43 ccsdu2009 阅读(241) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理