[코드트리] - 특정 연산을 이행하는 함수

LSDrug·2024년 8월 12일
0

문제풀이

목록 보기
13/21

특정 연산을 이행하는 함수 ⭕


문제

https://www.codetree.ai/training-field/search/problems/functions-that-perform-certain-operations?&utm_source=clipboard&utm_medium=text


풀이

해당 문제에 따라서 코드를 짜면 쉽게 풀 수 있는 문제이다.


코드

#include <iostream>
using namespace std;

int main() {
    int n;
    for(int i = 0; i < 3; i++) {
        cin >> n;

        if(n % 2 == 0) cout << n / 2 << " ";
        else cout << (n * 3) - 20 << " ";
    }
    return 0;
}

profile
마약같은 코딩, 마약같은 코딩러

0개의 댓글

관련 채용 정보