【发布时间】:2013-05-01 08:21:35
【问题描述】:
如问题所示。我正在做一个任务,其中边界被定义为某个数字,而内部 2d 数组需要一些计算。我写道:
for(int col = 0; col < this.w; col++){
energyMatrix[0][col] = 195075;
energyMatrix[this.h-1][col] = 195075;
}
for(int row = 1; row < this.h - 1; row++){
energyMatrix[row][0] = 195075;
energyMatrix[row][this.w-1] = 195075;
}
但是还有另一种(更快的)方法可以做到这一点吗?
【问题讨论】:
-
不——没关系,这部分代码可能不是瓶颈——它通常是需要优化的内部处理,如果有的话。
标签: loops multidimensional-array