[코테]/[GroomEdu]
[COS PRO 2급] 4차 4번_조교의 수 구하기 (C/C++)
Sky_
2021. 5. 19. 22:10
주어진 코드
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int solution(int classes[], int classes_len, int m) {
int answer = 0;
for (int i = 0; i < classes_len; i++) {
answer += classes[i] m; //빈칸
if (classes[i] m != 0) //빈칸
answer++;
}
return answer;
}
int main() {
int classes[] = { 80, 45, 33, 20 };
int m = 30;
int ret = solution(classes, 4, m);
printf("solution 함수의 반환 값은 %d 입니다.\n", ret);
}
완성 코드
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
int solution(int classes[], int classes_len, int m) {
int answer = 0;
for (int i = 0; i < classes_len; i++) {
answer += classes[i] / m;
if (classes[i] - m != 0)
answer++;
}
return answer;
}
int main() {
int classes[] = { 80, 45, 33, 20 };
int m = 30;
int ret = solution(classes, 4, m);
printf("solution 함수의 반환 값은 %d 입니다.\n", ret);
}
예시
classes | classes_len | n | return |
[80, 45, 33, 20] | 4 | 30 | 8 |
goorm
구름은 클라우드 기술을 이용하여 누구나 코딩을 배우고, 실력을 평가하고, 소프트웨어를 개발할 수 있는 클라우드 소프트웨어 생태계입니다.
www.goorm.io