[프로그래머스/C++]Lv.0 - 주사위의 개

YH J·2023년 4월 19일
0

프로그래머스

목록 보기
49/168

문제 링크

https://school.programmers.co.kr/learn/courses/30/lessons/120845

내 풀이

각길이를 n으로 나눈 값을 전부 곱해주면된다.

내 코드

#include <string>
#include <vector>

using namespace std;

int solution(vector<int> box, int n) {
    int answer = 0;
    answer = (box[0]/n)*(box[1]/n)*(box[2]/n);
    return answer;
}

다른 사람의 풀이

#include <string>
#include <vector>

using namespace std;

int solution(vector<int> box, int n) {
    return (box[0] / n) * (box[1] / n) * (box[2] / n);
}

다른 사람의 풀이 해석

리턴을 바로 해준다.

profile
게임 개발자 지망생

0개의 댓글