티스토리 뷰
주어진코드
#include <stdio.h> #include <stdbool.h> #include <stdlib.h> int func_a(int passed, int non_passed) { return (passed > 1 && non_passed == 0); } int func_b(int scores[3]) { int answer = 0; if(scores[0] < 40) { answer++; } if(scores[1] < 44) { answer++; } if(scores[2] < 35) { answer++; } return answer; } int func_c(int scores[3]) { int answer = 0; if(scores[0] >= 80) { answer++; } if(scores[1] >= 88) { answer++; } if(scores[2] >= 70) { answer++; } return answer; } int solution(int scores[][3], int scores_len) { int answer = 0; for(int i = 0; i<scores_len; i++) { int passed = ; //빈칸 int non_passed = ; //빈칸 answer += ; //빈칸 } return answer; } int main() { int scores1[2][3] = { {30, 40, 100}, {97, 88, 95} }; int ret1 = solution(scores1, 2); printf("solution 함수의 반환 값은 %d 입니다.\n", ret1); int scores2[6][3] = { {90, 88, 70}, {85, 90, 90}, {100, 100, 70}, {30, 90, 80}, {40, 10, 20}, {83, 88, 80} }; int ret2 = solution(scores2, 6); printf("solution 함수의 반환 값은 %d 입니다.\n", ret2); }
완성코드
#include <stdio.h> #include <stdbool.h> #include <stdlib.h> int func_a(int passed, int non_passed) { return (passed > 1 && non_passed == 0); } int func_b(int scores[3]) { int answer = 0; if(scores[0] < 40) { answer++; } if(scores[1] < 44) { answer++; } if(scores[2] < 35) { answer++; } return answer; } int func_c(int scores[3]) { int answer = 0; if(scores[0] >= 80) { answer++; } if(scores[1] >= 88) { answer++; } if(scores[2] >= 70) { answer++; } return answer; } int solution(int scores[][3], int scores_len) { int answer = 0; for(int i = 0; i<scores_len; i++) { int passed = func_c(scores[i]); int non_passed = func_b(scores[i]); answer += func_a(passed, non_passed); } return answer; } int main() { int scores1[2][3] = { {30, 40, 100}, {97, 88, 95} }; int ret1 = solution(scores1, 2); printf("solution 함수의 반환 값은 %d 입니다.\n", ret1); int scores2[6][3] = { {90, 88, 70}, {85, 90, 90}, {100, 100, 70}, {30, 90, 80}, {40, 10, 20}, {83, 88, 80} }; int ret2 = solution(scores2, 6); printf("solution 함수의 반환 값은 %d 입니다.\n", ret2); }
goorm
구름은 클라우드 기술을 이용하여 누구나 코딩을 배우고, 실력을 평가하고, 소프트웨어를 개발할 수 있는 클라우드 소프트웨어 생태계입니다.
www.goorm.io
'[코테] > [GroomEdu]' 카테고리의 다른 글
[COS PRO 2급] 4차 3번_획득 점수 구하기. 도박은 안되요 (C/C++) (0) | 2021.05.19 |
---|---|
[COS PRO 2급] 4차 1번_상담 선생님은 너무 바빠요 (C/C++) (0) | 2021.05.18 |
[COS PRO 2급] 3차 10번_내 절반이 여기에 있는거야? (C/C++) (0) | 2021.05.17 |
[COS PRO 2급] 3차 9번_주차장에 몇대가 들어올수 있는거야? (C/C++) (0) | 2021.05.17 |
[COS PRO 2급] 3차 8번_TV 애청자 A씨 (C/C++) (0) | 2021.05.16 |
댓글
공지사항
최근에 올라온 글
TAG
- cospro기출
- YBM기출
- 구름에듀
- YBM
- CosPro
- Cos Pro
- C
- COSPRO 2급
- 코스프로
- lv1
- cospro기출문제
- 구름에듀 기출문제
- 배열활용문제
- groomedu
- c언어 기출문제
- programmers
- Java
- 프로그래머스
- 구름 기출문제
- c언어
- C++
- 알고리즘
- lv2
- groom
- 배열
- 연습문제
- 1급
- 자바
- 코딩테스트
- 기출문제
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함