ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Transpuesta De Una Matriz


Enviado por   •  18 de Febrero de 2014  •  364 Palabras (2 Páginas)  •  301 Visitas

Página 1 de 2

#include <stdio.h>

#include <stdlib.h>

int **traspuesta(int **m, int f, int c)

{

int i, j;

int **t = (int**)malloc(c * sizeof *t);

for(i = 0; i < c; i++)

{

*(t + i) = (int*)malloc(f * sizeof *t[i]);

for(j = 0; j < m[0][j]; j++)

*(*(t + i) + j) = *(*(m + j) + i);

}

return t;

}

int main()

{

int n = 3, m = 3, i, j, **trasp;

int **matriz = (int**)malloc(n * sizeof(int*));

for(i = 0; i < m; i++)

*(matriz + i) = (int*)malloc(m * sizeof(int));

for(i = 0; i < n; i++)

for(j = 0; j < m; j++)

{

printf("Elemento %d,%d: ", i + 1, j + 1);

scanf("%d", &matriz[i][j]);

}

trasp = traspuesta(matriz, n, m);

for(i = 0; i < n; i++)

{

for(j = 0; j < m; j++)

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

printf("\n");

}

system("pause");

return 0;

}

...

Descargar como (para miembros actualizados) txt (1 Kb)
Leer 1 página más »
Disponible sólo en Clubensayos.com