웅재의 코딩세상
[프로그래머스] 길이에 따른 연산 본문
- 풀이
#include <string>
#include <vector>
#include <numeric>
using namespace std;
int solution(vector<int> num_list) {
int answer = 0;
if(num_list.size() >= 11) answer = accumulate(num_list.begin(), num_list.end(),0);
else{
answer =1;
for(int i=0; i<num_list.size(); i++){
answer *= num_list[i];
}
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] A 강조하기 (0) | 2024.01.29 |
---|---|
[프로그래머스] 글자 이어 붙여 문자열 만들기 (0) | 2024.01.29 |
[프로그래머스] 원하는 문자열 찾기 (0) | 2024.01.29 |
[프로그래머스] 조건에 맞게 수열 변환하기 3 (0) | 2024.01.29 |
[프로그래머스] 배열에서 문자열 대소문자 변환하기 (0) | 2024.01.29 |