Analyze the number sequence on the 1 to the lower right corner from the upper left corner, we can easily discover their rules: the number K = (K 1) of the row on the diagonal line (k 1) - (k 1) 1, k = 0 ~ n-1, K 1 is because the array subscript starts from 0
So we can start from the number on the diagonal, when K> 1 is odd, to the left is increment, down is decremented; when k> 1 is even, the left is decremented, and the up is increased or decreased. The increase or decrease is the range of K, which is very simple to assign the array member.
The following processes run in BC3.1.
#include "stdio.h" #include "math.h" #define n 15
Void main () {Int a [n] [n], i, k; a [0] [0] = 1; for (k = 1; k