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

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

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

#include <functional>

#include <vector>

using namespace std;

int main()

{

const int VECTOR_SIZE = 8 ;

typedef vector<int> IntVector ;

typedef IntVector::iterator IntVectorIt ;

IntVector Numbers(VECTOR_SIZE) ;

IntVectorIt start, end, it, location ;

Numbers[0] = 4 ;

Numbers[1] = 10;

Numbers[2] = 11 ;

Numbers[3] = 30 ;

Numbers[4] = 69 ;

Numbers[5] = 70 ;

Numbers[6] = 96 ;

Numbers[7] = 100;

start = Numbers.begin() ;

end = Numbers.end() ;

cout << "Numbers { " ;

for(it = start; it != end; it)

cout << *it << " " ;

cout << " }\n" << endl ;

location = lower_bound(start, end, 30) ;

cout << "First location element 10 can beinserted in Numbers is:"<< location - start1<< endl ;

return 0;

}

输出结果:

Numbers { 4 10 11 30 69 70 96 100 }

"First location element 10 can beinserted in Numbers is: 4

与lower_bound()相同

查找大于x的第一个位置

必须是先排好序的数组

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

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

int p=upper_bound(a,a7,2)-a;

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

return 0;

}

输出结果:2 foundat 3

setiosflags(ios::fixed) 固定的浮点显示

setiosflags(ios::scientific) 指数表示

setiosflags(ios::left) 左对齐

setiosflags(ios::right) 右对齐

setiosflags(ios::skipws) 忽略前导空白

setiosflags(ios::uppercase) 16进制数大写输出

setiosflags(ios::lowercase) 16进制小写输出

setiosflags(ios::showpoint) 强制显示小数点

setiosflags(ios::showpos) 强制显示符号


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

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

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