Problem 1: create an array that represents a 3 X 3 matrix: 1 2 3 4 5 6 7 8 9 Transpose the matrix: 1 4 7 2 5 8 3 6 9 In other words aij  aji Put the transposition operation in a function. Print out the two arrays in main(). Use both matrix [][] operations and perform again with pointers.

Respuesta :

Answer:

Check the explanation

Explanation:

C code:

#include <stdio.h>

void cal_transpose(int arr1[3][3],int transpose[3][3])

{

for (int i = 0; i < 3; ++i)

for (int j = 0; j < 3; ++j) {

transpose[j][i] = arr1[i][j];

}

}

int main()

{

int arr1[3][3]={1,2,3,4,5,6,7,8,9};

int transpose[3][3];

cal_transpose(arr1,transpose);

printf("matrix arr1 : \n");

for (int i = 0; i < 3; ++i)

{ for (int j = 0; j < 3; ++j) {

printf("%d ",arr1[i][j]);

}

printf("\n");

}

printf("Transpose matrix : \n") ;

for (int i = 0; i < 3; ++i)

{

for (int j = 0; j < 3; ++j) {

printf("%d ",transpose[i][j]);

}

printf("\n");

}

return 0;

}

CODE OUTPUT:

Ver imagen temmydbrain