b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

c++ strchr函数_strchr函数返回_模拟实现strchr函数(19)

电脑杂谈  发布时间:2017-02-28 08:29:56  来源:网络整理

it = adjacent_find (it, myvector.end(), myfunction);

if (it!=myvector.end())

cout << "the second consecutive repeated elements are: "<< *it << endl;

return 0;

}

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

int a[1000]={1,2,3,3,3,4,4,5};

int y=count(a,a8,3); //(数组名,查询的数组长度,查询个数的数字)

cout<<"number of times "<<y<<endl;

return 0;

}

输出结果:

number of times 3

#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

int main()

{

int ival , searchValue;

vector<int> ivec;

cout<<"Enter some integers(CtrlZ to end):"<<endl;

while(cin >> ival)

ivec.push_back(ival);

cin.clear();// 使输入流重新有效

cout<<"Enter an integer you want to search:"<<endl;

cin>>searchValue;

cout<<count(ivec.begin() , ivec.end() , searchValue)

<<" elements in thevector have value "

<<searchValue<<endl;

return 0;

}

#include <vector>

#include <algorithm>

#include <iostream>

using namespace std;

bool greater10(int value)

{

return value >10;

}

int main()

{

vector<int> v1;

vector<int>::iterator Iter;

v1.push_back(10);

v1.push_back(20);

v1.push_back(10);

v1.push_back(40);

v1.push_back(10);

cout << "v1 : ";

for (Iter = v1.begin(); Iter != v1.end(); Iter)

cout << *Iter << " ";

cout << endl;

vector<int>::size_typeresult1 = count_if(v1.begin(), v1.end(), greater10); //count_if算法返回使谓词函数返回条件成立的元素个数


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-34960-19.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...