You are viewing a single comment's thread. Return to all comments →
int main() {
int n; int col = 0; int row = 0; scanf("%d", &n); int matrix[(n * 2) - 1][(n * 2) - 1]; int tmp = n; for(col = 0; col < (n * 2) - 1; col++) { for(row = col; row < ((n * 2) - 1) - col; row++) { matrix[col][row] = tmp; matrix[row][col] = tmp; matrix[((n * 2) - 2) - col][row] = tmp; matrix[row][((n * 2) - 2) - col] = tmp; } tmp--; } for (int k = 0; k <(n * 2) - 1; k++) { for (int l = 0; l <(n * 2) - 1; l++) { printf("%d ", matrix[k][l]); } printf("\n"); } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Printing Pattern Using Loops
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
int main() {
}