fork(1) download
  1. #include <stdio.h>
  2. #define NOERROR 0
  3. int bit(int n)
  4. {
  5. if(n==0)
  6. printf("0");
  7. else if(n==1)
  8. printf("1");
  9. else{
  10. printf("%d",n%2);bit(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. }
  25.  
Success #stdin #stdout 0s 5320KB
stdin
10
stdout
0以上の整数を入力してください:0101