C++ 벡터 값 있는지 확인

1 개요[ | ]

C++ 벡터 값 있는지 확인
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<int> v = {11, 1, 12, 2};
    cout << (find(v.begin(), v.end(), 2) != v.end()) << endl; // 1 (exists)
    cout << (find(v.begin(), v.end(), 3) != v.end()) << endl; // 0 (not exists)
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}