웅재의 코딩세상
[프로그래머스] x만큼 간격이 있는 n개의 숫자 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
vector<long long> solution(int x, int n) {
vector<long long> answer(n);
answer.front() = x;
for(int i =0; i<n-1; i++){
answer.at(i+1) = answer.at(i) + x;
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 1' 카테고리의 다른 글
[프로그래머스] 핸드폰 번호 가리기 (0) | 2024.02.09 |
---|---|
[프로그래머스] 행렬의 덧셈 (0) | 2024.02.09 |
[프로그래머스] 직사각형 별찍기 (0) | 2024.02.09 |
[프로그래머스] 예산 (0) | 2024.02.09 |
[프로그래머스] 3진법 뒤집기 (0) | 2024.02.09 |