Advertisement
Guest User

Prog2Prob3

a guest
May 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. bool isMember(int a[], int b, int c);
  4.  
  5. int main()
  6. {
  7. int x[5];
  8. int z, y = 0;
  9. cout << "Enter 5 integers: \n";
  10. for (int i = 0; i < 5; i++)
  11. {
  12. cin >> x[i];
  13. y++;
  14. }
  15. cout << "Search: ";
  16. cin >> z;
  17. isMember(x, y, z);
  18. if (isMember(x, y, z))
  19. cout << "Integer found in array.";
  20. else
  21. cout << "Not found.";
  22. system("pause>0");
  23. }
  24.  
  25. bool isMember(int a[], int b, int c)
  26. {
  27. if (a[b] == c)
  28. return true;
  29. else if (b == 0)
  30. return false;
  31. else
  32. return(isMember(a, b - 1, c));
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement