비트단위논리연산
59. 비트단위로 바꿔 출력하기
#include <stdio.h>
int main(){
int a;
scanf("%d", &a);
printf("%d", ~a);
return 0;
}
60. 비트단위로 and 하여 출력하기 -> &
#include <stdio.h>
int main(){
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a&b);
return 0;
}
61. 비트단위로 xor 하여 출력하기 -> ^
#include <stdio.h>
int main(){
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a^b);
return 0;
}
62. 비트단위로 or 하여 출력하기 -> |
#include <stdio.h>
int main(){
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a|b);
return 0;
}
'코딩 > CodeUp - C 기초 100문제' 카테고리의 다른 글
| 기초 - 조건/선택실행구조 1065 ~ 1070 (0) | 2018.08.14 |
|---|---|
| 기초 - 삼항연산 1063, 1064 (0) | 2018.08.14 |
| 기초 - 논리연산 1053 ~ 1058 (0) | 2018.08.12 |
| 기초 - 비교연산 1049 ~ 1052 (0) | 2018.08.12 |
| 기초 - 비프시프트연산 1047, 1048 (0) | 2018.08.12 |