[7급 국가직 자료구조론 2024년 11번]

다음은 구조체 배열에서 최댓값을 찾아 출력하는 C 프로그램이다. (가), (나)에 들어갈 내용을 바르게 연결한 것은?
#include <stdio.h>
typedef struct _data {
	int value;
} DataType;
DataType *max(DataType *a) {
	int i, max = a[0].value, index = 0;
	for ( i = 0; i < 5; i++ )
		if ( max < a[i].value ) {
			max = a[i].value;
			index = i;
		}
	return (가);
}

int main(void)
{
	int i;
	DataType data[5], *result;
	for ( i = 0; i < 5; i++ )
		scanf("%d", &data[i].value);

	result = max(data);
	printf("max = %d",(나));
	return 0;
}
(가) (나)
자료구조론
  1. ①&a[index] result->value
  2. ②&a[index] result.value
  3. ③a[index] result->value
  4. ④a[index] (*result).value

선지를 골라 바로 채점해 보세요.

정답 ①

출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)

신고가 접수됐습니다. 감사합니다.

오류 신고