#include #pragma gcc optimize("O2") #define MAX 100 void transpose(int matrix[][MAX], int result[][MAX], int n, int m); int main(void) { int n, m; scanf("%d%d", &n, &m); int matrix[MAX][MAX]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &matrix[i][j]); } } int result[MAX][MAX]; transpose(matrix, result, n, m); for (int i = 0; i < m; i++) { for (int j = 0; j < n - 1; j++) { printf("%d ", result[i][j]); } printf("%d\n", result[i][n - 1]); } return 0; } void transpose(int matrix[][MAX], int result[][MAX], int n, int m) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { result[j][i] = matrix[i][j]; } } }