fork(2) download
  1. #include <stdio.h>
  2.  
  3. struct t { int hasColided; } table[] = {
  4. { .hasColided = 0 },
  5. { .hasColided = 1 },
  6. { .hasColided = 1 },
  7. { .hasColided = 1 },
  8. { .hasColided = 1 },
  9. { .hasColided = 0 },
  10. { .hasColided = 1 } };
  11. int size = 7;
  12.  
  13. int getNumPastasColididas(int i, int c) {
  14. return (i < size) ? table[i].hasColided + getNumPastasColididas(i + 1, c) : c;
  15. }
  16.  
  17. int main(void) {
  18. printf("%d", getNumPastasColididas(0, 0));
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 2112KB
stdin
Standard input is empty
stdout
5