fork download
  1. #include <stdio.h>
  2. int main( void )
  3. {
  4. unsigned int m, n, q, r, i;
  5. printf("m÷n\n");
  6. printf("m = ");scanf("%d", &m);
  7. printf("n = ");scanf("%d", &n);
  8.  
  9. q=0;
  10. r=0;
  11. i=8*sizeof(unsigned int);
  12. do {
  13. i--;
  14. r<<=1;
  15. r |= (0x01 & (m>>i));
  16. if(r>=n) {
  17. r-=n;
  18. q|= 0x01 << i;
  19. }
  20. } while(i!=0);
  21.  
  22. printf("商は%d\n", q);
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 1836KB
stdin
Standard input is empty
stdout
m÷n
m = n = 商は1