반응형

프로그래머스 3

행렬의 덧셈

프로그래머스 - 행렬의 덧셈 class Solution { public int[][] solution(int[][] arr1, int[][] arr2) { int[][] answer = new int[arr1.length][arr1[0].length]; for (int i = 0; i < answer.length; i++) { for (int j = 0; j < answer[i].length; j++) { answer[i][j] = arr1[i][j] + arr2[i][j]; } } return answer; } } https://programmers.co.kr/learn/courses/30/lessons/12950 코딩테스트 연습 - 행렬의 덧셈 행렬의 덧셈은 행과 열의 크기가 같은 두 행렬의 같은 행..

x만큼 간격이 있는 n개의 숫자

프로그래머스 - x만큼 간격이 있는 n개의 숫자 class Solution { public long[] solution(int x, int n) { long[] answer = new long[n]; answer[0] = x; for(int i = 1; i < n; i++){ answer[i] +=answer[i-1]+x; } return answer; } } https://programmers.co.kr/learn/courses/30/lessons/12954 코딩테스트 연습 - x만큼 간격이 있는 n개의 숫자 함수 solution은 정수 x와 자연수 n을 입력 받아, x부터 시작해 x씩 증가하는 숫자를 n개 지니는 리스트를 리턴해야 합니다. 다음 제한 조건을 보고, 조건을 만족하는 함수, solutio..

직사각형 별찍기

프로그래머스 - 직사각형 별찍기 import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); for(int i = 0; i < b; i++){ for(int j = 0; j < a; j++){ System.out.print("*"); } System.out.println(""); } } } https://programmers.co.kr/learn/courses/30/lessons/12969 코딩테스트 연습 - 직사각형 별찍기 이 문제에는 표준 입력으로 두 개의 ..

반응형