fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // Declarar e inicializar la matriz
  6. const int n = 4; // Tamaño de la matriz (n x n)
  7. int matrix[n][n] = {
  8. {1, 2, 3, 4},
  9. {2, 1, 2, 3},
  10. {3, 2, 1, 2},
  11. {4, 3, 2, 1}
  12. };
  13.  
  14. // Verificar si la matriz es simétrica
  15. bool isSymmetric = true;
  16. for (int i = 0; i < n; i++) {
  17. for (int j = 0; j < n; j++) {
  18. if (matrix[i][j] != matrix[j][i]) {
  19. isSymmetric = false;
  20. break;
  21. }
  22. }
  23. if (!isSymmetric) {
  24. break;
  25. }
  26. }
  27.  
  28. // Mostrar el resultado
  29. if (isSymmetric) {
  30. cout << "La matriz es simétrica." << endl;
  31. } else {
  32. cout << "La matriz no es simétrica." << endl;
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
La matriz es simétrica.