#include#includeusingnamespacestd;boolmyfunction(inti,intj){return(i==j);}intmain(){intmyints[]={10,20,20,20,30,30,20,20,10};//102020203030202010vectormyvector(myin" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

unique

系統 1885 0
      // unique algorithm example

#include <iostream>

#include <algorithm>

#include <vector>

using namespace std;



bool myfunction (int i, int j) {

  return (i==j);

}



int main () {

  int myints[] = {10,20,20,20,30,30,20,20,10};    // 10 20 20 20 30 30 20 20 10

  vector<int> myvector (myints,myints+9);

  vector<int>::iterator it;



  // using default comparison:

  it = unique (myvector.begin(), myvector.end()); // 10 20 30 20 10 ?  ?  ?  ?

                                                  //                ^



  myvector.resize( it - myvector.begin() );       // 10 20 30 20 10



  // using predicate comparison:

  unique (myvector.begin(), myvector.end(), myfunction);   // (no changes)



  // print out content:

  cout << "myvector contains:";

  for (it=myvector.begin(); it!=myvector.end(); ++it)

    cout << " " << *it;



  cout << endl;



  return 0;

}


    

unique


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 涞源县| 闽侯县| 许昌市| 义马市| 柏乡县| 霍林郭勒市| 南陵县| 阿巴嘎旗| 南昌市| 平谷区| 乐东| 全南县| 马边| 通州市| 白水县| 抚松县| 云龙县| 舒城县| 怀集县| 元江| 辽宁省| 巴南区| 柳林县| 塔河县| 鹤壁市| 临朐县| 河池市| 保山市| 资中县| 城口县| 新安县| 海盐县| 分宜县| 伊春市| 乐东| 邹城市| 宁武县| 新营市| 柳江县| 莱州市| 城固县|