I did think quite a lot about this and was able to work out how all the variables and counters are going and how we arrive at the result.
However, is there any logic to support Mark Byer's solution here, or is it just adjusted so that all the counters fall in place?
Please give me a logical explanation for the algorithm
Code
#include <stdio.h>
int main()
{
int x[3][3] = {1, 2, 3,
4, 5, 6,
7, 8, 9};
int n = 3;
for (int slice = 0; slice < 2 * n - 1; ++slice) {
printf("Slice %d: ", slice);
int z = slice < n ? 0 : slice - n + 1;
for (int j = z; j <= slice - z; ++j) {
printf("%d ", x[j][slice - j]);
}
printf("\n");
}
return 0;
}