Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool check_if_number_exists(int a[], int n, int nr)
- {
- if (n == - 1)
- return false;
- if (a[n - 1] == nr)
- return true;
- return check_if_number_exists(a, n - 1, nr);
- }
- bool check_duplicates(int a[], int n)
- {
- if (n == 1)
- return false;
- if (check_if_number_exists(a, n -1, a[n - 1]))
- return true;
- return check_duplicates(a, n - 1);
- }
- int main()
- {
- int a[] = {1, 2, 6, 3, 5};
- cout << check_duplicates(a, 5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement