문제 설명
정수가 들어 있는 배열 num_list가 매개변수로 주어집니다. num_list의 원소의 순서를 거꾸로 뒤집은 배열을 return하도록 solution 함수를 완성해주세요.
제한사항
1 ≤ num_list의 길이 ≤ 1,000
0 ≤ num_list의 원소 ≤ 1,000
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
// num_list_len은 배열 num_list의 길이입니다.
int* solution(int num_list[], size_t num_list_len) {
// return 값은 malloc 등 동적 할당을 사용해주세요. 할당 길이는 상황에 맞게 변경해주세요.
int* answer = (int*)malloc(sizeof(int)*num_list_len);
for(int i=0;i<num_list_len ;i++)
{
answer[i] = num_list[num_list_len-i-1];
}
return answer;
}
'C언어' 카테고리의 다른 글
[프로그래머스-C언어] 문자 반복 출력하기 (0) | 2024.05.25 |
---|---|
[프로그래머스-C언어] 중복된 숫자 개수 (0) | 2024.05.25 |
[프로그래머스-c언어] 세균증식 (0) | 2024.05.25 |
[프로그래머스-C언어] 배열 원소의 길이 (0) | 2024.05.25 |
[프로그래머스-C언어] 중앙값 구하기 (0) | 2024.05.25 |