Created
February 6, 2016 19:45
-
-
Save RamonLopezEscudero/fd4162866912ef0fe18b to your computer and use it in GitHub Desktop.
Transpuesta de una matriz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
/* ---------------------------------- */ | |
int i, j; | |
int n_row, n_col; | |
/* ---------------------------------- */ | |
printf("Programa para calcular la matriz transpuesta\n \n"); | |
/* Entrada de las dimensiones de la matriz a operar */ | |
printf("Ingrese las dimensiones de la matriz\n"); | |
printf("Numero de filas: "); | |
scanf("%i", &n_row); | |
printf("Numero de columas: "); | |
scanf("%i", &n_col); | |
/* ---------------------------------- */ | |
float matriz[n_row][n_col], matriz_transpuesta[n_col][n_row]; | |
/* ---------------------------------- */ | |
/* Iteracion de entrada de datos */ | |
for (i = 0; i < n_row; i++) | |
{ | |
printf("\nValores del renglon %i \n", i + 1); | |
for (j = 0; j < n_col; j++) | |
{ | |
printf("Ingrese el elemento %i: ", j + 1); | |
scanf("%f", &matriz[i][j]); | |
} | |
} | |
/* Transpuesta de la matriz */ | |
for (i = 0; i < n_row; i++) | |
{ | |
for (j = 0; j < n_col; j++) | |
{ | |
matriz_transpuesta[j][i] = matriz[i][j]; | |
} | |
} | |
/* Impresion de los resultados */ | |
printf("\nVector Resultado:\n"); | |
for (i = 0; i < n_row; i++) | |
{ | |
printf("[ "); | |
for (j = 0; j < n_col; j++) | |
{ | |
printf("%f ", matriz_transpuesta[i][j]); | |
} | |
printf("]\n"); | |
} | |
printf("\n"); | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment