코딩테스트/[C#] 프로그래머스
[프로그래머스 | C# | Lv.0] 길이에 따른 연산
냠냠쿠
2023. 8. 15. 18:52
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/181879
📝 나의 풀이
using System;
public class Solution {
public int solution(int[] num_list) {
int answer = 1;
for(int i=0; i<num_list.Length; i++){
if(11<=num_list.Length){
answer +=num_list[i];
} else {
answer *=num_list[i];
}
}
if(11<=num_list.Length) answer -=1;
return answer;
}
}
728x90