Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个 MxN 数组,我应该对这个数组求和,如下图所示;
数组总和
我应该对所有 x、所有 y、所有 z 和所有 g 求和。我需要一种方法。My_Brain.exe 已停止,我找不到解决此问题的任何方法。
SumColumnZigZag(column) { Sum = 0 for row = 0; row < rows; row++ { sum += array[row][column + (row % 2)*(1 - 2*(column % 2))] } return sum }
% 是模运算符