ビット演算
ビットパターンを表示するサンプル
#include <stdio.h>
void bitpat( int x )
{
int i;
for ( i = 31; i>=0; i-- )
printf( "%d", ( x >> i ) & 0x00000001 );
printf( "\n" );
}
void main()
{
int a;
while ( scanf( "%d", &a ) != EOF )
bitpat( a );
}
Comments