(2022.06.16) #define 사용하기 #50
BurningFalls
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
자주 사용하는 코드를 #define을 통해 나만의 코드로 remake해서 사용하면 편리하다.
지금까지 문제를 풀어오면서 하나하나 추가해온, 현재 내가 사용하는 #define 전체 틀은 아래와 같다.
(#define 대신 typedef를 사용해도 별 다를 바는 없다.)
#define ALL(V) v.begin(), v.end()
는 다음과 같이 사용한다.sort(v.begin(), v.end())
->sort(ALL(v))
lower_bound(v.begin(), v.end(), x)
->lower_bound(ALL(v), x)
단, 만들어진 vector의 처음부터 끝까지 모든 부분을 포함하기 때문에, vector를 동적 할당하지 않고 최대 크기로 선언하고 초기화를 했다면, 일부만 사용해야 하는 경우
ALL(v)
를 사용해서는 안 된다.Beta Was this translation helpful? Give feedback.
All reactions