Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int leMatriz(int m, int n, int **matriz){
- int i,j;
- for(i=0; i < m; i++){
- for(j = 0; j < n; j++){
- printf("\nInsira a posicao [%d][%d] da matriz: ", i+1, j+1);
- scanf("%d", &matriz[i][j]);
- }
- }
- }
- void imprimirDinamico(int n, int m, int **matriz){
- int i,j;
- for(i=0; i < n; i++){
- for(j=0;j < m; j++){
- printf("%d \t",matriz[i][j]);
- }
- printf("\n");
- }
- }
- void ex514(){
- int **matrizA, **matrizB;
- int a,b,i;
- printf("Insira as dimensoes da matriz (linha,coluna): \n");
- scanf("%d %d", &a,&b);
- /* ALOCAÇÃO DE MEMORIA PARA A MATRIZ */
- matrizA = (int**)malloc(a*sizeof(int*));
- for(i=0; i < a; i++){
- matrizA[i] = (int*)malloc(b*sizeof(int));
- }
- matrizB = (int**)malloc(b*sizeof(int*));
- for(i=0; i < b; i++){
- matrizB[i] = (int*)malloc(a*sizeof(int));
- }
- leMatriz(a,b,matrizA);
- transposta(a,b,matrizA,matrizB);
- imprimirDinamico(a,b,matrizB);
- }
- void transposta(int a, int b, int **matrizA, int **matrizB){
- int i,j;
- for(i=0; i < a; i++){
- for(j=0; j < b; j++){
- matrizB[j][i] = matrizA[i][j];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement