📄 chapter11-1.cpp
字号:
//文件名:CHAPTER11-1.cpp
#include <algorithm>
#include <iostream>
using namespace std;
void main()
{
const int ARRAY_SIZE = 8 ;
int IntArray[ARRAY_SIZE] = { 1, 2, 3, 4, 4, 5, 6, 7 } ;
int *location ; // stores the position for the first pair of matching consecutive elements.
int i ;
// print content of IntArray
cout << "IntArray { " ;
for(i = 0; i < ARRAY_SIZE; i++)
cout << IntArray[i] << ", " ;
cout << " }" << endl ;
location = adjacent_find(IntArray, IntArray + ARRAY_SIZE) ;
//print the matching consecutive elements if any were found
if (location != IntArray + ARRAY_SIZE) // matching consecutive elements found
cout << "Found adjacent pair of matching elements: (" << *location << "," << *(location + 1) << "), " <<"at location " << location - IntArray << endl;
else // no matching consecutive elements were found
cout << "No adjacent pair of matching elements were found"<< endl ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -