fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. typedef std::vector<int>::const_iterator VectIter;
  6.  
  7. bool find (VectIter begin, VectIter end, int value)
  8. {
  9. while (begin != end)
  10. {
  11. if (*begin == value)
  12. return true;
  13. begin++;
  14. }
  15. return false;
  16. }
  17.  
  18. int main()
  19. {
  20. std::vector<int> v = {1, 2, 3, 4, 5, 6, 7};
  21. std::vector<int>::const_iterator it = v.begin();
  22.  
  23. std::cout << find (v.begin(), v.end(), 4) << std::endl;
  24. std::cout << find (v.begin(), v.begin(), 1) << std::endl;
  25. std::cout << find (v.begin(), v.end(), 13) << std::endl;
  26. }
  27.  
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
1
0
0