ビット演算

ビットパターンを表示するサンプル

#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 );
}

C > 演算 | comments (0) | trackbacks (0)

Comments

Comment Form

icons:

Trackbacks