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

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

unique

系統 1906 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條評論
主站蜘蛛池模板: 扬中市| 珲春市| 电白县| 洮南市| 阳朔县| 永登县| 贡嘎县| 宁武县| 渑池县| 花莲县| 张家口市| 稻城县| 策勒县| 云龙县| 溧阳市| 吉首市| 团风县| 绍兴市| 宁南县| 阳曲县| 伊宁市| 神木县| 霞浦县| 宁明县| 抚远县| 辽阳县| 临漳县| 泗水县| 黑水县| 日喀则市| 临沂市| 正安县| 都昌县| 苏尼特右旗| 桂东县| 榆中县| 西乌珠穆沁旗| 信丰县| 中牟县| 长垣县| 宜兰市|