행렬의 덧셈 Level 1
12345678910111213141516171819202122 int[][] sumMatrix(int[][] A, int[][] B) { int row = A.length; //행의 길이 int col = A[0].length; // 열의 길이 int[][] answer = new int[row][col]; for(int i = 0 ; i<row; i++){ for(int j =0 ; j<col; j++){ answer[i][j] = A[i][j] + B[i][j]; } } return answer; } #행렬 순서 [0][0] [0][1] [1][0] [1][1] cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | int[][] sumMatrix(int[][] A, int[][] B) { int row = A.length; //행의 길이 int col = A[0].length; // 열의 길이 int[][] answer = new int[row][col]; for(int i = 0 ; i<row; i++){ for(int j =0 ; j<col; j++){ answer[i][j] = A[i][j] + B[i][j]; } } return answer; } #행렬 순서 [0][0] [0][1] [1][0] [1][1] | cs |
'프로그래밍 > 알고리즘(자바)' 카테고리의 다른 글
평균구하기 Level 1 : For each문 (0) | 2018.05.06 |
---|---|
문자열 내림차순으로 배치하기 Level 1 #Collections,join,sort,asList,reverse (0) | 2018.05.06 |
짝수와 홀수 Level 1 (0) | 2018.05.05 |
서울에서김서방찾기 Level 1 (0) | 2018.05.05 |
나누어 떨어지는 숫자 배열 Level 1 (0) | 2018.05.05 |