一层循环实现方法,缺点是MoveNext比较复杂一点---条件比较多。 void PrintSquareArray(int n, int* A) { int origin_x = 0; int origin_y = 0; int current_size = n; int current_x = 0; int current_y = 0; do { printf("%d (%d)\n", A[current_x*n + current_y], current_size);
}while(MoveNext(origin_x, origin_y, current_size, current_x, current_y)); } bool MoveNext(int &origin_x, int &origin_y, int &square_size, int ¤t_x , int ¤t_y) { int x = current_x - or