Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool isMember(int a[], int b, int c);
- int main()
- {
- int x[5];
- int z, y = 0;
- cout << "Enter 5 integers: \n";
- for (int i = 0; i < 5; i++)
- {
- cin >> x[i];
- y++;
- }
- cout << "Search: ";
- cin >> z;
- isMember(x, y, z);
- if (isMember(x, y, z))
- cout << "Integer found in array.";
- else
- cout << "Not found.";
- system("pause>0");
- }
- bool isMember(int a[], int b, int c)
- {
- if (a[b] == c)
- return true;
- else if (b == 0)
- return false;
- else
- return(isMember(a, b - 1, c));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement