Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char* argv[]) {
  5.  
  6.     int num, r, i = 0;
  7.     int rests[256];
  8.    
  9.     char buffer[256];
  10.  
  11.     printf("Inserisci un fottuto numero: ");
  12.  
  13.     scanf("%s", buffer);
  14.     num = atoi(buffer);
  15.  
  16.     for(; num != 0; i++) {
  17.         r = num%2;
  18.         num /= 2;
  19.         rests[i] = r;
  20.     }
  21.  
  22.     for(i-=1; i >= 0; i--)
  23.         printf("%d", rests[i]);
  24.  
  25.     printf("\n");
  26. }
Add Comment
Please, Sign In to add comment