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

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

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

cout << "The number of elements in v1greater than 10 is:"<< result1 << "." <<endl;

return 0;

}

输出结果:

v1 : 10 20 10 40 10

The number of elements in v1 greater than10 is: 2.

#include<vector>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

int array[10]={10,20,30,40};

vector<int> v;

v.push_back(1);

v.push_back(2);

v.push_back(3);

v.push_back(4);

vector<int>::iterator p;

p=find(v.begin(),v.end(),3);//p=从头找到尾,找3

if(p!=v.end()) //如果p还没到结尾的时候,就找到3了,则输出3

cout<<*p<<endl;

p=find(v.begin(),v.end(),9);//p=从头找到尾,找9

if(p==v.end()) //如果p到最后了,也就是没找到,则输出not found

cout<<"not found "<<endl;

p=find(v.begin()1,v.end()-2,1);

if(p!=v.end())

cout<<*p<<endl;

int *pp=find(array,array4,20);

cout<<*pp<<endl;

return 0;

}

输出结果:3

not found

3

20

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

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

int x=find(a,a7,3)-a;

cout<<x1<<endl;

return 0;

}

输出结果:

4

不用STL模板时

#include<algorithm>

用STL模板时

#include<algorithm>

#include <vector>

查找大于或者等于x的第一个位置

必须是先排好序的数组

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

int a[100]={1,2,23,33,45,56,123};

int p=lower_bound(a,a7,35)-a;

cout<<35<<" found at"<<p1<<endl;

return 0;

}

输出结果:35 foundat 5

#include <iostream>

#include <algorithm>


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

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

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