output every bit of an integer
#include <stdio.h>
#include <math.h>
int main ()
{
int i = 0;
int y = 0;
int j = 0;
int z = 0;
int x = 0;
scanf ("%d", &i);
j = i;
Computes the bit number of the integer while
(j)
{
j = J/10;
y++;
}
printf ("This number has%d bits \ n", y);
Outputs the number for each digit for
(x=0; x<y; y--)
{
z = i/(int) (POW (y-1));
i = i% (int) (POW (y-1));
printf ("%d", z);
}
return 0;
}
two int integer binary tab, how many bit bits are different.
#include <stdio.h> int main () {int x = 0;
int y = 0;
int i = 0;
int j = 0;
int count = 0;
scanf ("%d,%d", &x,&y); i = (sizeof (x>y) (x:y)) *8;
Bit printf used to compute the larger value ("The larger number in the two digits has%d bit bits \ n", i);
For (j=0 j<i; j + +)////////////////////////////////////////////////////////////// count++;
The cumulative one at a time}//two digits to the right one x = x>>1;
y = y>>1;
printf ("%d digits different \ n", count);
return 0; }