fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int g=0;
  6.  
  7. void un(int n){
  8. if(n>0){
  9. int r;
  10. r = rand()%10;
  11. if(r==0){
  12. un(n+1);
  13. }else{
  14. g=g+1;
  15. un(n-1);
  16. }
  17. }
  18. }
  19.  
  20. int main(void) {
  21. srand(time(NULL));
  22. un(100);
  23. printf("%d",g);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
116