알고리즘

제작/기타 프로그램

[C#] 행렬 계산기 (5) - 곱셈 계산

코드 : static public Matrix Multiplex(Matrix m1, Matrix m2) { //if(m1.row != m2.column) return; Matrix res = new Matrix(m1.row,m1.column); for(int i = 0; i < m1.row; i++) { for(int j = 0; j < m1.column; j++) { for(int k = 0; k < m1.column; k++) { res.matrix[i][j] += m1.matrix[i][k] * m2.matrix[k][j]; } } } return res; }

App/Kotlin

[Kotlin] Null 처리 방식

fun main( ) { var str1: String = "Hello World!" str1 = null //오류! null을 처리할 수 없다. println("str1: $str1") } 실행 결과 Error: Kotlin: Null can not be a value of a nonnull type String 이렇듯 단순 null을 삽입하여 처리 불가하다. null 처리하기 fun main() { var str1 : String? = "Hello World!" str1 = null println("str1: $str1") } 실행 결과 str1: null null을 처리하기 위해 자료형 뒤에 ?를 붙혔다. 세이프 콜과 NPE 강제 발생 fun main() { var str1 : String? = "..

Dev.Poinguinie
'알고리즘' 태그의 글 목록