• C++笔记


    void f(vector<Entry>& ve,list<Entry>& le)
    {
        sort(ve.begin(),ve.end());
        unique_copy(ve.begin(),ve.end(),le.begin());
    }
    
    
    
    void f(vector<Entry>&ve,list<Entry>&le)
    {
        sort(ve.begin(),ve.end());
         unique_copy(ve.begin(),ve.end(),back_inserter(le));//append to le
    }
    
    void f(list<Entry>&ve,vector<Entry>&le)
    {
        copy(ve.begin(),ve.end(),le);//error: le not aniterator
        copy(ve.begin(),ve.end(),le.end());//bad: writes beyond the end
        copy(ve.begin(),ve.end(),le.begin());//overwrite elements
    }
    string::const  iterator  i = find(s.begin(),s.end(),c);
    
    void  f()
    {
    string  m = "Mary  had  a  little  lamb";
    int  a  count = count(m,´a´);
    }
    
    
    void  f(list<complex>& lc, vector<string>& vs, string  s)
    {
    int  i1 = count(lc.begin(),lc.end(),complex(1,3));
    int  i2 = count(vs.begin(),vs.end(),"Diogenes");
    int  i3 = count(s.begin(),s.end(),´x´);
    }
    
    void  g(char  cs[], int  sz)
    {
    int  i1 = count(&cs[0],&cs[sz],´z´);    // ’z’s in array
    int  i2 = count(&cs[0],&cs[sz/2],´z´);    // ’z’s in first half of array
    }
  • 相关阅读:
    放大镜
    简单拖拽加边界处理加轨迹返回
    事件委托
    数组的方法
    数据处理
    数组去重
    字符串的操作方法
    函数的递归调用
    选择排序、冒泡排序
    Linux—shell中$(( ))、$( )、``与${ }的区别
  • 原文地址:https://www.cnblogs.com/mengqingzhong/p/3049537.html
Copyright © 2020-2023  润新知