Network disconnection
Description
한 학생의 과목별 점수가 들어있는 배열이 주어졌을 때, 이 학생의 최고 점수와 최저 점수를 제외한 나머지 점수들의 합계를 구하려 합니다. 이를 위해 다음과 같이 4단계로 프로그램 구조를 작성했습니다.
1. 모든 과목 점수의 합을 구합니다.
2. 최고 점수를 구합니다.
3. 최저 점수를 구합니다.
4. (모든 과목 점수의 합) - (최고 점수) - (최저 점수)의 값을 return 합니다.
학생의 과목별 점수가 들어있는 배열 scores와 scores의 길이 scoreslen이 매개변수로 주어질 때, 학생의 과목별 점수에서 최고 점수와 최저 점수를 제외한 나머지 점수의 합을 return 하도록 solution 함수를 작성하려 합니다. 위 구조를 참고하여 코드가 올바르게 동작할 수 있도록 빈칸에 주어진 funca, funcb, funcc 함수를 알맞게 채워주세요.
매개변수 설명
학생의 과목별 점수가 들어있는 배열 scores와 scores의 길이 scores_len이 solution 함수의 매개변수로 주어집니다.
- scores의 길이 scores_len은 3 이상 10 이하의 자연수입니다.
- 학생의 점수는 0점 이상 100점 이하의 정수이며, 같은 점수를 받은 과목은 없습니다.
return 값 설명
solution 함수는 학생의 과목별 점수에서 최고 점수와 최저 점수를 제외한 나머지 점수의 합을 return 합니다.
예시
scores | scores_len | return |
---|---|---|
{50, 35, 78, 91, 85} | 5 | 213 |
예시 설명
예시 #1
- 가장 높은 점수 : 91점
- 가장 낮은 점수 : 35점
가장 높은 점수와 가장 낮은 점수를 제외한 나머지 점수들의 합은 50 + 78 + 85 = 213점입니다.
Fill type challenge HOWTO
- In the Fill type challenge, you have to fill the blank with appropriate code
- The given code except the blank cannot be edited.
- An error message will be shown in the Result area when you leave the blank empty.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int func_a(int s[], int arr_size){
int ret = 0;
for(int i = 0; i < arr_size; ++i)
if(s[i] > ret)
ret = s[i];
return ret;
}
int func_b(int s[], int arr_size){
int ret = 0;
for(int i = 0; i < arr_size; ++i)
ret += s[i];
return ret;
}
int func_c(int s[], int arr_size){
int ret = 101;
for(int i = 0; i < arr_size; ++i)
if(s[i] < ret)
ret = s[i];
return ret;
}
int solution(int scores[], int scores_len) {
int sum = func_;
int max_score = func_;
int min_score = func_;
return sum - max_score - min_score;
}
Result
Stop
Result of [Run] or [Submit] will be displayed here