fork(4) download
  1. #include <stdio.h>
  2. int py_mod(int a, int b)
  3. {
  4. if (a < 0)
  5. if (b < 0)
  6. return -(-a % -b);
  7. else
  8. return -a % b - (-a % -b != 0 ? 1 : 0);
  9. else if (b < 0)
  10. return -(a % -b) + (-a % -b != 0 ? 1 : 0);
  11. else
  12. return a % b;
  13. }
  14. int main(void) {
  15. printf("%d", py_mod(10, -4));
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 2156KB
stdin
Standard input is empty
stdout
-1