Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, n = 10;
- //4
- int SumElem(int i)
- {
- if(i == n-1) return a[i];
- else return a[i] + SumElem(i+1);
- }
- int Cautare(int i, int x)
- {
- if(i != n-1)
- {
- if(a[i] != x) return Cautare(i+1, x);
- else return 1;
- }
- return 0;
- }
- int main()
- {
- cout << SumElem(0) << "\n\n";
- cout << Cautare(0, 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement