c++39 [C++] 3항 연산자 (A>B) ? B : A (A>B) ? B : A 괄호 안에 들어있는게 '참'이면 앞에 걸(B) 출력 괄호 안에 들어있는게'거짓'이면 뒤에 걸(A) 출력 (A>B) ? B : A 이면 '작은 걸 출력' 하는 것이 된다. (AB) ? A : B ) 식 전체에 괄호 한 번 더 쳐야지 제대로 작동된다. ex) 1267번 핸드폰 요금 #include #include #include #include #include using namespace std; int main(void) { int n; cin >> n; int sum = 0; int call; int fee01 = 0; int fee02 = 0; for (int i = 1; i > call; cout 2023. 3. 4. [C++] 공백 포함 문자열 입력 받기 공백 포함 문자열 입력 받기 그냥 string객체에 cin으로 받으면 공백으로 구분이 된다. 1. getline 이용 2023. 3. 4. [C++] 입력 속도, cin속도 ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cs cin cout보다 printf, scanf가 더 빠름 ※ endl보다 \n을 사용하는 것이 더 빠름 https://algwang.tistory.com/10 C++ cin, cout 입출력 속도 높이기 일반적으로 cin과 cout은 printf, scanf와 비교했을 때 속도가 현저히 느리다. 그냥 사용한다해도 이 차이로 시간초과가 발생하는 경우를 만나보지 못했고 cin과 cout이 훨씬 편하다고 느꼈기 때문에 그 algwang.tistory.com 2023. 3. 2. [C++] '변수(이)가 모호합니다' 오류 해결 https://cplusplus.com/reference/algorithm/count/?kw=count https://cplusplus.com/reference/algorithm/count/?kw=count function template std::count template typename iterator_traits ::difference_type count (InputIterator first, InputIterator last, const T& val); Count appearances of value in range Returns the number of elements in the range [first,last) that co cplusplus.com namespace std에 count라는 .. 2023. 3. 2. 이전 1 2 3 4 ··· 10 다음