[프로그래머스] 자바 - x만큼 간격이 있는 n개의 숫자
2021. 10. 19. 16:04
class Solution {
public long[] solution(int x, int n) {
long[] answer = {};
return answer;
}
}
<풀이>
class Solution {
public long[] solution(int x, int n) {
long[] answer = new long[n];
long temp = x;
for(int i=0; i<n; i++){
answer[i] = x *(i+1);
}
return answer;
}
}
class Solution {
public long[] solution(int x, int n) {
long[] answer = new long[n];
//long temp = x;
for(int i=0; i<n; i++){
answer[i] = (long)x *(i+1);
}
return answer;
}
}
'Algorithm Study > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 자바 - 핸드폰 번호 가리기 (0) | 2021.10.19 |
---|---|
[프로그래머스] 자바 - 직사각형 별찍기 (0) | 2021.10.19 |
[프로그래머스] 자바 - 짝수와 홀수 (0) | 2021.10.18 |
[프로그래머스] 자바 - 평균구하기 (0) | 2021.10.18 |