微尘 C语言C++基础教程培训2汇编内存角度零基础知识项目实战软件安全
代码
object Solution {
def setZeroes(matrix: Array[Array[Int]]): Unit = {
import scala.collection.mutable.ArrayBuffer val arrayBuffer = new ArrayBuffer[Int]()
val arrayBuffer2 = new ArrayBuffer[Int]()
import scala.collection.mutable.Map val map = Map[Int,Int]()
for(i<- 0 to matrix.length-1){
for(j<- 0 to matrix(i).length-1){
if(matrix(i)(j)==0){
arrayBuffer.append(i)
arrayBuffer2.append(j)
}
}
}
for(x<- arrayBuffer2.toArray) {
// 行置为0
for (i <- 0 to matrix.length - 1) {
matrix(i)(x) = 0
}
}
for(x<- arrayBuffer.toArray) {
// 列置为 0
for (j <- 0 to matrix(0).length - 1) {
matrix(x)(j) = 0
}
}
}}