fork download
  1. #include <stdio.h>
  2.  
  3. #define MAX 3
  4.  
  5. int GLOBAL_COUNT = MAX;
  6.  
  7. void contador();
  8.  
  9. int main() {
  10. for(int i = 0; i <= 7; i++) {
  11. contador();
  12. }
  13. return 0;
  14. }
  15.  
  16. void contador() {
  17. if (GLOBAL_COUNT <= 0) {
  18. GLOBAL_COUNT = MAX;
  19. }
  20. printf("chamada: %d/%d\n", GLOBAL_COUNT, MAX);
  21. GLOBAL_COUNT--;
  22. }
  23.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
chamada: 3/3
chamada: 2/3
chamada: 1/3
chamada: 3/3
chamada: 2/3
chamada: 1/3
chamada: 3/3
chamada: 2/3