Grupo de C++
Publico Grupo
Publico Grupo
Active an hour
Este grupo esta relacionado con nuestro curso profesional de C++. Aquí se comparten temas generales... View more
Publico Grupo
Responder a: Ayuda ejemplo 5. Matrices
Claro, seria de gran ayuda.
/* Matriz simétrica
Una matriz es simétrica si es cuadrada y si es igual a su transpuesta */
#include<iostream>
using namespace std;
int main(){
int filas = 0, columnas = 0;
char condicion = ‘F’;
cout<<“Ingrese el numero de filas: “;
cin>>filas;
cout<<“Ingrese el numero de columnas: “;
cin>>columnas;
cout<<endl;
int matriz[filas][columnas] = {};
for(int i = 0; i < filas; i++){
for(int j = 0; j < columnas; j++){
cout<<“Ingrese valor [“<<i<<“][“<<j<<“]: “;
cin>>matriz[i][j];
}
}
cout<<“————————————————“<<endl;
cout<<“Matriz original: “<<endl;
for(int i = 0; i < filas; i++){
for(int j = 0; j < columnas; j++){
cout<<matriz[i][j];
}
cout<<endl;
}
cout<<“————————————————“<<endl;
cout<<“Matriz transpuesta: “<<endl;
for(int i = 0; i < columnas; i++){
for(int j = 0; j < filas; j++){
cout<<matriz[j][i];
}
cout<<endl;
}
cout<<endl;
if(filas == columnas){
for(int i = 0; i < filas; i++){
for(int j = 0; j < columnas; j++){
if(matriz[i][j] == matriz[j][i]){
condicion = ‘V’;
}
}
}
}else{
cout<<“La matriz no es cuadrada por lo tanto: “<<endl;
}
if(condicion == ‘V’){
cout<<“La matriz es simetrica.”;
}else{
cout<<“La matriz no es simetrica.”;
}
cout<<endl;
return 0;
}