Advertisement
J00ker

(10-28)T

Oct 27th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, n = 10;
  6.  
  7. //4
  8. int SumElem(int i)
  9. {
  10. if(i == n-1) return a[i];
  11. else return a[i] + SumElem(i+1);
  12. }
  13.  
  14. int Cautare(int i, int x)
  15. {
  16. if(i != n-1)
  17. {
  18. if(a[i] != x) return Cautare(i+1, x);
  19. else return 1;
  20. }
  21. return 0;
  22. }
  23.  
  24. int main()
  25. {
  26. cout << SumElem(0) << "\n\n";
  27. cout << Cautare(0, 0);
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement