다음은 원형 연결 리스트(circular linked list)의 길이를 구하는 C 언어 프로그램이다. ㉠ ~ ㉢에 들어갈 내용으로 옳게 짝지은 것은?
typedef struct node {
int key;
struct node *link;
} list_node;
int length(list_node *ptr) {
list_node *temp;
int count = 0;
if (㉠) {
temp = ptr;
do {
count++;
㉡;
} while (㉢);
}
return count;
} ㉠ ㉡ ㉢
- ①ptr != NULL temp = temp→link temp != ptr
- ②ptr == NULL temp = temp→link temp == ptr
- ③ptr != NULL ptr = temp→link temp != ptr
- ④ptr == NULL ptr = temp→link temp == ptr
선지를 골라 바로 채점해 보세요.
정답 ①
출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)