Last active
October 25, 2016 05:09
-
-
Save tarcisio-marinho/86c4d13f80bddb9d69923a6c9d0c9b9b to your computer and use it in GitHub Desktop.
4th bit de um numero inteiro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void binary(int array[]){ | |
int n,i,j,a; | |
i=0; | |
scanf("%d",&n);fflush(stdin); | |
if(n<8){ | |
printf("0\n"); | |
}else if(n==8){ | |
printf("1\n"); | |
} | |
else{ | |
while(n>0){ | |
array[i]=n%2; | |
n/=2; | |
++i; | |
} | |
for(j=i-1;j>=0;--j){ | |
a++; | |
if(a==4){ | |
printf("%d",array[j]); | |
} | |
}printf("\n"); | |
} | |
} | |
int main(){ | |
int array[100]={0}; | |
binary(array); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment