2019~2020/정보 과학
비트 연산자 실습
유진
2019. 3. 27. 10:21
반응형
#include <stdio.h>
int main()
{
int a,b;
printf("입력: ");
scanf("%d %d", &a, &b);
printf("%d\n", a&b); //and 비트 연산 두개의 비트가 모두 1일때 1
printf("%d\n", a|b); //or 비트 두개의 비트 중 하나라도 1이면 1
printf("%d\n", a^b); //xor 비트 두개의 비트 중 하나만 1일때 1
printf("%d\n", ~a); //not 비트가 1이면 0, 0이면 1
printf("%d\n", a>>2); // l - shift
printf("%d\n", a<<3); // R - shift
}반응형