Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- N번째큰수
- 호반우 상인
- 22869
- hcpc
- BOJ
- 쌤쌤쌤
- c++ #입출력 #속도 #ios #sync_with_stdio #cin #cout #tie
- c++ #boj #
- 백준
- 백준 #다익스트라 #dijkstra #9370 #c++
- 이분탐색 #dp #11053
- 16202
- graph #최단경로
- 최소 #공배수 #최대 #공약수 #유클리드 #호제법 #lcm #gcd #c++ #boj #3343 #백준 #장미
- backtracking #codetree #디버깅 #삼성코테
- 진법변환 #2to10 #10to2 #이진법 #십진법 #변환 #bitset #c++
- 30870
- graph
- boj #백준
- 1174
- 투포인터 #백준 #boj #20922 #22862
- 3343
- LIS #가장긴증가하는부분수열 #
- 사이클 없는 그래프
- 줄어드는수
- 레드아보
- 코딩
- C++
- 20117
- 3D #Reconstruction #computer #vision #volume #metric #tsdf #kinect #fusion
Archives
- Today
- Total
hyunjin
[C++][비교,논리 연산] 본문
728x90
[1053]
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
scanf("%d %d",&a);
cout<<!a;
return 0;
}
0이면 1로 1이면 0으로 출력하기
[1055]
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
scanf("%d %d",&a,&b);
cout<< (a || b);
return 0;
}
왜인지 모르겠지만 출력할 때 ()를 빼니 0 1 input으로 넣었을 때 0이 나온다.
왜지?
[1057] 같을 때 참
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
scanf("%d %d",&a,&b);
cout<< (a == b);
return 0;
}
!(a==b) 이걸로 하면 xor 연산자 되겠다.
[1058] 모두 거짓 일 때만 참
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
scanf("%d %d",&a,&b);
cout<< !(a || b);
return 0;
}
0 0 일때만 1이 나오게, 하나라도 참이 있다면 거짓.
!a && !b도 같은 표현
728x90
'알고리즘 연습 > 코드업' 카테고리의 다른 글
[C++][삼항연산자]1064 (0) | 2020.09.04 |
---|---|
[C++][비트 단위 논리 연산] 1059~ 보수 , ~, & ,| ,^, << ,>> (0) | 2020.09.04 |
[C++][기초- 비트 시프트 연산자] (0) | 2020.09.03 |
[C++][기초-출력변환] 8진,16진 (0) | 2020.09.02 |
[C++][기초-데이터형]1028~1029 (0) | 2020.09.02 |