Programmers Solutions/Level-1
[프로그래머스] x만큼 간격이 있는 n개의 숫자
률무차
2021. 2. 3. 04:01
title: "x만큼 간격이 있는 n개의 숫자"
category: 프로그래머스[Level-1]
tags: [C++, JavaScript, 프로그래머스]
date: "2021-01-21"
문제 링크
C++
#include <string>
#include <vector>
using namespace std;
vector<long long> solution(int x, int n) {
vector<long long> answer;
for(int i=1; i<=n; i++){
answer.push_back(x*i);
}
return answer;
}
JavaScript
function solution(x, n) {
var answer = [];
for (let i = 1; i <= n; i++) {
answer.push(x * i);
}
return answer;
}
728x90
반응형