1234567891011121314151617181920212223242526272829303132333435 |
- #include <stdio.h>
- void transpose_matrix(int matrix[3][3]) {
- int temp;
- int i,j;
- for (i = 0; i < 3; ++i) {
- for (j = i + 1; j < 3; ++j) {
- temp = matrix[i][j];
- matrix[i][j] = matrix[j][i];
- matrix[j][i] = temp;
- }
- }
- }
- int main() {
- int matrix[3][3];
- int i,j;
- for (i = 0; i < 3; ++i) {
- for (j = 0; j < 3; ++j) {
- scanf("%d", &matrix[i][j]);
- }
- }
- transpose_matrix(matrix);
- for (i = 0; i < 3; ++i) {
- for (j = 0; j < 3; ++j) {
- printf("%d ", matrix[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
|