⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter11-1.cpp

📁 C++STL程序员开发指南
💻 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 + -