피자 나눠 먹기 1

canyi·2023년 3월 29일
0

프로그래머스

목록 보기
15/17

문제링크

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

나의 풀이

#include <string>
#include <vector>

using namespace std;

int solution(int n) {
    int answer = 0;
    
    if(n % 7 == 0){
        return answer  = n / 7 ;
    }
    
    else{
        return answer = n / 7 + 1;
    }
    
}

남의 풀이


![](https://velog.velcdn.com/images/piaocanyi/post/dc7dd47f-7740-4e37-9cb4-5bbc4e8d2749/image.jpg)
![](https://velog.velcdn.com/images/piaocanyi/post/dceca439-6cd4-4366-a1e5-88214dd1c530/image.jpg)
![](https://velog.velcdn.com/images/piaocanyi/post/a6925a52-fc86-4925-b313-4712b46eb3a1/image.jpg)
#include <string>
#include <vector>

using namespace std;

int solution(int n) {
    int answer = (n+6)/7;
    return answer;
}
profile
백엔드 개발 정리

0개의 댓글