想问一下为什么输出一直是1的死循环?
预期的的结果应该是输出一个n阶的拐角方阵,例如n=3时输出:
1 1 1
1 2 2
1 2 3
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
int main()
{
int n;
int x[25][25];
int i,j,k;
int m, l;
while (scanf("%d", &n) != EOF) {
for (k = 1; k <= n; k++) {
for (i = k; i <= n; i++) {
x[k][i] = k;
}
for (j = k; j <= n; j++) {
x[j][k] = k;
}
}
for (m = 1; m <= n; m++) {
for (l = 1; l <= n; n++) {
printf("%d ", x[m][l]);
}
printf("\n");
}
}
}