fork download
  1. #include <stdio.h>
  2.  
  3. int divide(int dividend, int divisor) {
  4. int a = dividend, b = divisor, times = 1;
  5. while (a > b) {
  6. if (a > (b + b)) {
  7. b += b;
  8. times += times;
  9. } else if (a < (b + b)) {
  10. a -= b;
  11. b = divisor;
  12. }
  13. }
  14. return times;
  15. }
  16.  
  17. int main(void) {
  18. int A, B;
  19. scanf("%d%d", &A, &B);
  20. printf("%d", divide(A, B));
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5288KB
stdin
10 3
stdout
2