C++

    [C++] 이러한 피연산자와 일치하는 ">>" 연산자가 없습니다.

    이러한 피연산자와 일치하는 ">>" 연산자가 없습니다. 피연산자 형식이 std::istream >> std::string 입니다. -> 해결: #include "string" 추가

    [C++] 범위기반 for문(ranged-based for statement)

    범위기반 for문(ranged-based for statement) for (element_declaration : array) statement 루프는 각 array의 요소를 반복하여 element_declaration에 선언된 변수에 현재 배열 요소의 값을 할당. 최상의 결과를 얻으려면 element_declaration이 배열 요소와 같은 자료형이어야 함 참고 https://boycoding.tistory.com/210

    [C++] switch-case 문

    switch(n){ case 1: //do sth break; case 2: //do sth break; default: //do sth }

    [C++] new/delete 이용한 2차원 배열 동적할당

    1차원 배열 int* arr = new int[x]; 2차원 배열 int** arr = new int*[x]; for(int i = 0; i < x; ++i) arr[i] = new int[y];

    [C++] 소수점 반올림/올림/내림/버림

    출력만 하는 경우 형식 지정자 %.2f 를 사용 ( 몇번째 자리에서 반올림 하냐에 따라 숫자 변경 int main(void) { float myfloat = 37.777779; printf("%.2f", myfloat); } 출력: 37.78 연산을 하는 경우 1) 내림/반올림/올림에 따라 각 각 의 floor() / ceil() / floor() 함수 사용 #include float val = 37.777779; float rounded_down = floor(val); /* 내림: 37 */ float nearest = floor(val + 0.5); /* 반올림: 38 */ float rounded_up = ceil(val); /* 올림: 38 */ 반올림의 경우 내림 함수인 floor()에서 +0..