上一页 1 ··· 45 46 47 48 49 50 51 52 53 ··· 99 下一页

2011年7月29日

countif http://www.cplusplus.com/reference/algorithm/count_if/

摘要: // count_if example#include <iostream>#include <algorithm>#include <vector>using namespace std;bool IsOdd (int i) { return ((i%2)==1); }int main () { int mycount; vector<int> myvector; for (int i=1; i<10; i++) myvector.push_back(i); // myvector: 1 2 3 4 5 6 7 8 9 mycount = 阅读全文

posted @ 2011-07-29 22:40 more think, more gains 阅读(152) 评论(0) 推荐(0) 编辑

merge http://www.cplusplus.com/reference/algorithm/merge/

摘要: // merge algorithm example#include <iostream>#include <algorithm>#include <vector>using namespace std;int main () { int first[] = {5,10,15,20,25}; int second[] = {50,40,30,20,10}; vector<int> v(10); vector<int>::iterator it; sort (first,first+5); sort (second,second+5); 阅读全文

posted @ 2011-07-29 22:31 more think, more gains 阅读(179) 评论(0) 推荐(0) 编辑

replace http://www.cplusplus.com/reference/algorithm/replace/

摘要: // replace algorithm example#include <iostream>#include <algorithm>#include <vector>using namespace std;int main () { int myints[] = { 10, 20, 30, 30, 20, 10, 10, 20 }; vector<int> myvector (myints, myints+8); // 10 20 30 30 20 10 10 20 replace (myvector.begin(), myvector.end 阅读全文

posted @ 2011-07-29 22:29 more think, more gains 阅读(293) 评论(0) 推荐(0) 编辑

for_each stl http://www.cplusplus.com/reference/algorithm/for_each/(转载)

摘要: // for_each example#include <iostream>#include <algorithm>#include <vector>using namespace std;void myfunction (int i) { cout << " " << i;}struct myclass { void operator() (int i) {cout << " " << i;}} myobject;int main () { vector<int& 阅读全文

posted @ 2011-07-29 22:25 more think, more gains 阅读(114) 评论(0) 推荐(0) 编辑

count http://www.cplusplus.com/reference/algorithm/count/

摘要: // count algorithm example#include <iostream>#include <algorithm>#include <vector>using namespace std;//count 他查找一个元素出现的次数int main () { int mycount; // counting elements in array: int myints[] = {10,20,30,30,20,10,10,20}; // 8 elements mycount = (int) count (myints, myints+8, 10); 阅读全文

posted @ 2011-07-29 22:19 more think, more gains 阅读(176) 评论(0) 推荐(0) 编辑

上一页 1 ··· 45 46 47 48 49 50 51 52 53 ··· 99 下一页

导航