我想学习
程序代码:
#include<stdio.h> int f(int row, int col, int n) { if(n - row - 1 < row) row = n - row - 1; if(n - col - 1 < col) col = n - col - 1; return ((row < col) ? row : col) + 1; } int main() { int i, j, n; scanf("%d", &n); for(i = 0; i < n; i++, putchar('\n')) for(j = 0; j < n; j++) printf("%4d", f(i, j, n)); return 0; }