본문 바로가기
C++

[프로그래머스] 짝수의 합

by 띰쥬 2025. 9. 2.
728x90
반응형
SMALL

#include <string>
#include <vector>

using namespace std;

int solution(int n) {
    int answer = 0;
    
    for(int i=1; i<n+1; i++)
        answer += i%2==0 ? i:0;
    return answer;
}

728x90
반응형
LIST

댓글