fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int a,b,q,r,sw;
  6. printf("整数を入力:"); scanf("%d %d",&a,&b);
  7. if(a%b == 0)
  8. {
  9. q = a / b;
  10. sw = 0;
  11. }
  12. else
  13. {
  14. q = a / b;
  15. r = a % b;
  16. sw = 1;
  17. }
  18. switch(sw)
  19. {
  20. case 0: printf("%d÷%d=%d",a,b,q);
  21. case 1: printf("%d÷%d=%d余り%d",a,b,q,r);
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5288KB
stdin
12
4
stdout
整数を入力:12÷4=312÷4=3余り0