STL_Algorithm2: equal, mismatch, lexicographical_compare
来源:互联网 发布:怎样经营好一家淘宝店 编辑:程序博客网 时间:2024/06/11 08:35
#include <iostream>
using std::cout;
using std::endl;
#include <algorithm>
#include <vector>
#include <iterator>
int main()
{
const int SIZE = 10;
int a1[SIZE] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int a2[SIZE] = {1, 2, 3, 4, 1000, 6, 7, 8, 9, 10 };
std::vector< int > v1( a1, a1 + SIZE );
std::vector< int > v2( a1, a1 + SIZE );
std::vector< int > v3( a2, a2 + SIZE );
std::ostream_iterator< int > outputIt( cout, " " );
cout<< "Vector v1 contains: ";
std::copy( v1.begin(), v1.end(), outputIt );
cout<<"/nVector v2 contains: ";
std::copy( v2.begin(), v2.end(), outputIt );
cout<<"/nVector v3 contains: ";
std::copy( v3.begin(), v3.end(), outputIt );
bool result = std::equal( v1.begin(), v1.end(), v2.begin() );
cout<< "/n/nVector v1 "<<( result ? "is":"is not")
<<" equal to vector v2./n";
result = std::equal( v1.begin(), v1.end(), v3.begin() );
cout<<"Vector v1 "<<( result ? "is":"is not" )
<< " equal to vector v3./n";
std::pair< std::vector< int >::iterator, std::vector< int >::iterator > location;
location = std::mismatch( v1.begin(), v1.end(), v3.begin() );
cout<<"/nThere is a mismatch between v1 and v3 at "
<< "location "<<(location.first - v1.begin() )
<< "/nwhere v1 contains "<<*location.first
<<" and v3 contains "<<*location.second
<<"/n/n";
char c1[SIZE] = "HELLO";
char c2[SIZE] = "BYE BYE";
result = std::lexicographical_compare(c1, c1 + SIZE, c2, c2 + SIZE );
cout<< c1
<< ( result ? " is less than " : " is greater than or equal to " )
<< c2 <<endl;
return 0;
}
- STL_Algorithm2: equal, mismatch, lexicographical_compare
- find_first_of,adjacent_find,equal,mismatch,lexicographical_compare大杂烩
- STL比较范围(equal, lexicographical_compare, mismatch)
- STL_算法_区间的比较(equal、mismatch、 lexicographical_compare)
- mismatch和lexicographical_compare
- boost函数:equal、mismatch
- lexicographical_compare
- lexicographical_compare
- mismatch,equal比较两序列
- 非变异算法之比较(equal,mismatch)
- C++ STL算法系列5---equal() , mismatch()
- C++ STL算法系列5---equal() , mismatch()
- C++ STL算法系列5---equal() , mismatch()
- Effective STL 35 Case-insensitive string comparisons via mismatch or lexicographical_compare.
- effective stl 第35条:通过mismatch和lexicographical_compare实现简单的忽略大小写的字符串比较
- STL中用于比较的equal mismatch lexicographical_comapre
- std::lexicographical_compare
- mismatch
- C ++
- 求助
- 成员函数指针与高性能的C++委托(上篇)
- 10 12 23 就一个人
- ArcGIS Desktop 10新特性(七)
- STL_Algorithm2: equal, mismatch, lexicographical_compare
- 使用原子操作同步队列
- STL_Algorithm3: remove, remove_if, remove_copy, remove_copy_if
- 操作系统第七章-存储器管理
- 域名的概念与机制
- C语言编程经验总结
- GVIM/VIM 拦截到致命信号(deadly signa) SEGV 解决方法
- CSpinButtonCtrl控件的使用方法
- 我第一个用DirextX做的2D游戏——炮炮兵考眼力