Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Which loop is faster?

Name: Anonymous 2012-01-16 8:59


for (I = 0; I < N; I++)
  for (J = 0; J < M; J++)
    update(Xs[I][J]);

or

for (I = 0; I < N; I++)
  for (J = 0; J < M; J++)
    update(Xs[J][I]);

???

Name: Anonymous 2012-01-16 12:55

>>34

for (int i = 0; i < size; i++}
    array[size / i][size % i] = value;

The fuck is this?

1) First of all, division by zero in size / 0 and size % 0
2) Then, if size is 10, your indexes will be as follows:

10 0
5 0
3 1
2 2
2 0
1 4
1 3
1 2
1 1


You're not covering all the elements, and you are certainly going out of bounds if size = height * width.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List