본문 바로가기
C++/0x07-stl

find

by SpeeDr00t 2016. 7. 12.
반응형

find

1.소스

#include <iostream>
#include <cassert>
#include <algorithm>
#include <list>
#include <iterator>
using namespace std;

int main()
{
    int a[10] = {12, 3, 25, 7, 11, 213, 7, 123, 29, -31};

    // Find the first element equal to 7 in the array:
    int* ptr = find(&a[0], &a[10], 7);
    assert (*ptr == 7 && *(ptr+1) == 11);
    cout << *ptr << "\n";

return 0;

}

2.출력

g++ -o find1 find1.cpp

hacker@HACKER:~/cpp$ ./find1
7
반응형

'C++ > 0x07-stl' 카테고리의 다른 글

erase  (0) 2016.07.12
find & erase  (0) 2016.07.12
pair  (0) 2016.07.12
map  (0) 2016.07.11
set  (0) 2016.07.10