fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int ind(int a[], int size, int x){
  5. int j = 0;
  6. if (size == 0){
  7. return 0;
  8. }
  9. if (a[0] == x){
  10. ++j;
  11. }
  12. return j + ind(a+1,size-1, x);
  13. }
  14.  
  15. int main(){
  16. int a[5] = {1, 2, 3, 3, 5};
  17. cout << ind(a, 5, 3);
  18. }
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
2