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