c++39 [c++] c++루트 구하기 sqrt함수 c / c++에서 루트구하기 : sqrt함수 헤더파일 : c : #include c++ : #include ex) int x=9; int y=sqrt(x); >>y는 3이 저장된다. 함수 원형 : c언어 : double sqrt(double x) (=> 즉, 인수로 int를 넣으면 double로 형변환, 반환값을 int y로 받으면 int로 형변환 된다. 맞나?) c++ : double sqrt(doube x) float sqrt(float x) long double sqrt(long double x) ㄴ(함수 오버로딩으로 받는 인수, 반환형만 다르고 이름은 같게 해서 다른 함수를 정의함) ** sqrt : square root (제곱근) 예시 : sqrt(10)을 한다면 -> int main(void).. 2023. 2. 20. [c++] 동적 배열의 크기를 구할 수 있을까? 47 You can't. The size of an array allocated with new[] is not stored in any way in which it can be accessed. Note that the return type of new [] is not an array - it is a pointer(new연산자의 반환형은 배열이 아니라 포인터이다.) (pointing to the array's first element). So if you need to know a dynamic array's length, you have to store it separately.(:배열의 길이를 알고 싶으면 별도로 저장해야 합니다.) Of course, the proper way of doing .. 2023. 2. 18. [c++] * 배열 정리 1. 1차원 배열 동적 할당 (new) int *p_arr = new int[10]; 2. 2차원 배열 동적 할당(new) int **arr =new int*[ROW]; for(int i=0; i 2023. 2. 18. [c++] c++제곱 연산 int c=2; c**2; 이런 연산이 안된다. 제곱 연산자가 없다. pow함수를 사용해야한다. ( 라이브러리 사용 ) ex) #include int c=2; int d=pow(c,2); >>d에는 4가 저장된다. ㄴpow함수는 double pow(double , double) float pow(float, float) lonog double pow(long double , long double)이지만, int에 넣어도 자동으로 형변환 된다.double->int로) ㄴc++ 함수 오버로딩으로 함수 이름은 pow로 같은데 매개변수 type을 다르게 해서 다른 함수로 정의된 것이다. 2023. 2. 18. 이전 1 2 3 4 5 6 7 ··· 10 다음