fork download
  1. #include <stdio.h>
  2. #define NOERROR 0
  3.  
  4. int bit(int n)
  5. {
  6. if (n == 0)
  7. printf("0");
  8. else if (n == 1)
  9. printf("1");
  10. else {
  11. bit(n / 2);
  12. printf("%d", n % 2);
  13. }
  14. return 0;
  15. }
  16.  
  17. int main()
  18. {
  19. int x;
  20. do {
  21. printf("0以上の整数を入力してください:");
  22. scanf("%d", &x);
  23. } while (x < 0);
  24.  
  25. bit(x);
  26. printf("\n");
  27.  
  28. return NOERROR;
  29. }
Success #stdin #stdout 0s 5324KB
stdin
10
stdout
0以上の整数を入力してください:1010