help with search

Hi everybody, I want to print out the qualified items in a vector if a user decides to search for it. Please tell me how to do that?
With one of the following:
* A range-based for loop and an if statement.
* Repeated calls to std::find_if.
* Another list-like collection and a call to std::copy_if.

If you want more help, you'll need to be more specific, and preferably show that you've already tried to solve the problem on your own.

Take care!
-Albatross
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
	vector <int> v {1,2,3,4};
	int i=3;
	
	auto it= find(v.begin(), v.end(), i);
	if(it != v.end()) 
		cout << "number found!\n";
}
Topic archived. No new replies allowed.