프로그래머스 120924 다음에 올 숫자

Jmnote (토론 | 기여)님의 2023년 10월 29일 (일) 03:24 판 (새 문서: ==개요== {{프로그래머스|레벨=0|페이지=7}} ==C++== <syntaxhighlight lang='cpp'> #include <string> #include <vector> using namespace std; int solution(vector<int> common...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

프로그래머스 120924 다음에 올 숫자


2 C++

#include <string>
#include <vector>

using namespace std;

int solution(vector<int> common) {
    if(common[1]-common[0] == common[2]-common[1]) {
        return common[common.size()-1]+(common[1]-common[0]);
    }
    return common[common.size()-1]*(common[1]/common[0]);
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}