문제
정수 리스트 num_list와 정수 n이 주어질 때, n 번째 원소부터 마지막 원소까지의 모든 원소를 담은 리스트를 return하도록 solution 함수를 완성해주세요.
솔루션
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
// num_list_len은 배열 num_list의 길이입니다.
int* solution(int num_list[], size_t num_list_len, int n) {
// return 값은 malloc 등 동적 할당을 사용해주세요. 할당 길이는 상황에 맞게 변경해주세요.
int* answer = (int*)malloc(30);
int j = 0;
for(int i = n - 1; i < num_list_len; i++)
answer[j++] = num_list[i];
return answer;
}
https://school.programmers.co.kr/learn/courses/30/lessons/181892
'프로그래머스코딩테스트연습풀이 > C언어' 카테고리의 다른 글
[프로그래머스/C언어] 홀수 vs 짝수 (0) | 2023.08.01 |
---|---|
[프로그래머스/C언어] n개의 간격의 원소들 (0) | 2023.08.01 |
[프로그래머스/C언어] 카운트 다운 (0) | 2023.08.01 |
[프로그래머스/C언어] 접두사인지 확인하기 (0) | 2023.08.01 |
[프로그래머스/C언어] 문자열의 앞의 n글자 (0) | 2023.08.01 |