[코테]/[GroomEdu]
[COS PRO 2급] 5차 4번_선수가 획득한 점수 (C/C++)
Sky_
2021. 5. 24. 14:00

주어진 코드
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int solution(int taekwondo, int running, int shooting[], int shooting_len) {
int answer = 0;
if (taekwondo >= 25)
answer += 빈칸 ;
else
answer += taekwondo * 8;
answer += 250 + (60 - running) * 5;
int count = 0;
for (int i = 0; i < shooting_len; i++) {
answer += shooting[i];
if (shooting[i] == 10)
count++;
}
if (count >= 7)
answer += 빈칸 ;
return answer;
}
int main() {
int taekwondo = 27;
int running = 63;
int shooting[] = { 9, 10, 8, 10, 10, 10, 7, 10, 10, 10 };
int shooting_len = 10;
int ret = solution(taekwondo, running, shooting, shooting_len);
printf("solution 함수의 반환 값은 %d 입니다.\n", ret);
}
완성 코드
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int solution(int taekwondo, int running, int shooting[], int shooting_len) {
int answer = 0;
if (taekwondo >= 25)
answer += 250;
else
answer += taekwondo * 8;
answer += 250 + (60 - running) * 5;
int count = 0;
for (int i = 0; i < shooting_len; i++) {
answer += shooting[i];
if (shooting[i] == 10)
count++;
}
if (count >= 7)
answer += 100;
return answer;
}
int main() {
int taekwondo = 27;
int running = 63;
int shooting[] = { 9, 10, 8, 10, 10, 10, 7, 10, 10, 10 };
int shooting_len = 10;
int ret = solution(taekwondo, running, shooting, shooting_len);
printf("solution 함수의 반환 값은 %d 입니다.\n", ret);
}
예시
taekwondo | running | shooting | shooting_len | return |
27 | 63 | [9, 10, 8, 10, 10, 10, 7, 10, 10, 10] | 10 | 679 |
goorm
구름은 클라우드 기술을 이용하여 누구나 코딩을 배우고, 실력을 평가하고, 소프트웨어를 개발할 수 있는 클라우드 소프트웨어 생태계입니다.
www.goorm.io