fork download
  1. #include <stdio.h>
  2. int acc(int x)
  3. {
  4. int static scount=0,ans=0;
  5.  
  6. if(x == -1)
  7. {
  8. return ans;
  9. }
  10. else if(x == -2)
  11. {
  12. return scount;
  13. }
  14. else if(x >= 0)
  15. {
  16. ans += x;
  17. }
  18. else
  19. {
  20. return -1;
  21. }
  22. }
  23. int main(void)
  24. {
  25. printf("%d\n", acc(3));
  26. printf("%d\n", acc(4));
  27. printf("%d\n", acc(-3));
  28. printf("%d\n", acc(-2));
  29. printf("%d\n", acc(-1));
  30. printf("%d\n", acc(5));
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
0
0
-1
0
7
0