Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- 수광 소자
- 컴퓨터 그래픽스
- 통계학
- 자료구조
- queue
- Algorithm
- set
- 라인트레이서
- Arduino
- stl
- Visual Micro
- C언어
- 아두이노 소스
- Deque
- LineTracer
- 아두이노
- Array
- vector
- 시스템프로그래밍
- priority_queue
- html
- Stack
- map
- WinAPI
- 운영체제
- c++
- arduino compiler
- directx
- 아두이노 컴파일러
- list
Archives
- Today
- Total
Kim's Programming
Algorithm - count_if() 본문
소스)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<vector> #include<iostream> #include<algorithm> bool count_comp(int i) { if (i < 7) return true; return false; } void main() { std::vector<int> Vector = { 1, 3, 5, 7, 9, 11, 13, 15 }; std::cout << std::count_if(Vector.begin(), Vector.end(), count_comp) << std::endl; } | cs |
내용)
count_if(x,y,z) 함수는 iterator x가 가리키는 위치부터 iterator y가 가리키는 위치 사이에 있는 데이터들 중에서 z에 만족하는 값들의 갯수를 세서 리턴합니다.
결과)
'STL - Algorithm > Algorithm - Non-Modifying' 카테고리의 다른 글
| Algorithm - equal() (0) | 2016.02.07 |
|---|---|
| Algorithm - mismatch() (0) | 2016.02.07 |
| Algorithm - count() (0) | 2016.02.07 |
| Algorithm - adjacent_find() (0) | 2016.02.07 |
| Algorithm - find_first_of() (0) | 2016.02.07 |