문제풀이:
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int solution(vector<int> num_list) {
int answer = 0;
int even;
int odd;
for(int i=0; i<num_list.size();i++)
{
//홀수
if(i%2==0)
{
odd+=num_list[i];
}
else
{
even+=num_list[i];
}
}
answer = max(odd,even);
return answer;
}
'코딩테스트' 카테고리의 다른 글
프로그래머스_0단계_뒤에서 5등 위로 C++ (0) | 2024.04.23 |
---|---|
프로그래머스_0단계_소문자로 바꾸기 C++ (0) | 2024.04.23 |
프로그래머스_0단계_5명씩 C++ (0) | 2024.04.23 |
프로그래머스_0단계_할 일 목록 C++ (0) | 2024.04.23 |
프로그래머스_2단계_올바른 괄호_C++ (0) | 2024.04.11 |