欢迎光临散文网 会员登陆 & 注册

微尘 C语言C++基础教程培训2汇编内存角度零基础知识项目实战软件安全

2022-10-10 15:19 作者:olger2000  | 我要投稿

代码

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      }    }  }}


微尘 C语言C++基础教程培训2汇编内存角度零基础知识项目实战软件安全的评论 (共 条)

分享到微博请遵守国家法律