C++

근형·2024년 12월 31일

Q다음 배열의 값이 어떻게 출력될 지 손으로 풀고 알려주기

int arr[] = {0, 20, 30, 40. 50}
int* ptr = arr;
ptr += 2;
ptr[1] = 역참조 연산자(별표)ptr+ 10;

// 과연 arr의 값은 어떻게 채워져 있을까

arr 답
"{10,20,30,40,50}

배열 뒤집기

#include < vector >
#include < algorithm >

using namespace std;

vector< int > solution(vector< int > num_list) {
reverse(num_list.begin(), num_list.end());
return num_list;

}

0개의 댓글