Matrix transposition: Difference between revisions

Content added Content deleted
(→‎{{header|C}}: avoid unnecessary moves)
Line 239: Line 239:
double tmp;
double tmp;


for (start = 1; start < w * h - 2; start++) {
for (start = 0; start <= w * h - 1; start++) {
next = start;
next = start;
i = 0;
do { next = (next % h) * w + next / h; } while (next > start);
do { i++;
if (next < start) continue;
next = (next % h) * w + next / h;
} while (next > start);
if (next < start || i == 1) continue;


tmp = m[next = start];
tmp = m[next = start];