티스토리 뷰

 

 

구름에듀 5차 4번 문제

 

 

 

 

 

 


 

 

 

 

 

 

주어진 코드

#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

 

 

 

 

 

 

 

 


 

 

 

 

GroomEdu

 

goorm

구름은 클라우드 기술을 이용하여 누구나 코딩을 배우고, 실력을 평가하고, 소프트웨어를 개발할 수 있는 클라우드 소프트웨어 생태계입니다.

www.goorm.io

 

댓글