"프로그래머스 120924 다음에 올 숫자"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
==개요==
==개요==
{{프로그래머스|레벨=0|페이지=7}}
{{프로그래머스|레벨=0|페이지=7|분류=코딩테스트 입문}}


==C++==
==C++==

2023년 11월 26일 (일) 12:50 판

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]);
}
#include <string>
#include <vector>

using namespace std;

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