Answer the question
In order to leave comments, you need to log in
How to do what would be like in the example?
#include "stdio.h"
#define N 100
int main() {
int A[N][N];
int k = 1, j, i, p, n;
printf("Введите количество столбцов и строк: ");
scanf("%d", &n);
p = n / 2;
for (i = 1; i <= p; i++) {
for (j = n-i; j>=i ; j--) {
A[j][n - i] = k++;
}
for(j = n-i; j>=i; j--) {
A[i - 1][j] = k++;
}
for(j = n-i+1; j>=i;j--) {
A[n - j][i - 1] = k++;
}
for(j = n-i; j > i; j--) {
A[n - i][n - j] = k++;
}
}
if (n % 2 == 1) {
A[p][p] = n * n;
}
for (k = 0; k < n; k++)
for (j = 0; j < n; j++) {
printf(" %4d ", A[k][j]);
if (j == n - 1) printf("\n");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question