fork download
  1. #include <stdio.h>
  2.  
  3. int countGreater(int threshold, int a[], int N) {
  4. int res = 0;
  5. if(N > 0) {
  6. res = (a[0] > threshold);
  7. res += countGreater(threshold, a + 1, N - 1);
  8. }
  9. return res;
  10. }
  11.  
  12.  
  13. int N = 5;
  14. int grades[] = {19, 6, 17, 10, 8};
  15.  
  16. int main () {
  17. int numPositives = countGreater(9, grades, N);
  18. printf("Positivas: %d", numPositives);
  19. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
Positivas: 3