Ver Mensaje Individual
  #9 (permalink)  
Antiguo 29/01/2014, 13:20
ignatar20
 
Fecha de Ingreso: abril-2012
Ubicación: Malaga
Mensajes: 46
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Matriz bidimensional

Gracias, me ha servido de gran ayuda.
Por cierto, el ejercicio te dice que si hay 2 o más valores mayores iguales, está a nuestra elección cual elegir, asi que yo he puesto que siempre coja el ultimo mas grande.

Ahora tengo otro problema:
He hecho un programa para que me diga cuando una matriz es simetrica o no, pero a la hora de ejecutar el subprograma no me deja. Pongo el codigo para que lo entendais mejor
Código C++:
Ver original
  1. //============================================================================
  2. // Name        : simetrica.cpp
  3. // Author      : Francisco Ortega Avila
  4. // Version     :
  5. // Copyright   : Your copyright notice
  6. // Description : Hello World in C++, Ansi-style
  7. //============================================================================
  8.  
  9. #include <iostream>
  10. using namespace std;
  11. const int tam_array=50;
  12. typedef int Tmatriz[tam_array][tam_array];
  13. Tmatriz num;
  14. int fil,col,i,j,k,l;
  15. bool es=true;
  16. int matSime(int M[tam_array]);
  17.  
  18. int main() {
  19.     cout << "Introduzca el tamaño de la matriz: ";
  20.     cout << "Filas: ";
  21.     cin >> fil;
  22.     cout << "Columnas";
  23.     cin >> col;
  24.     for (i=0;i<fil;i++)
  25.     {
  26.         for(j=0;j<col;j++)
  27.         {
  28.             cout<<"Introduzca un numero: ";
  29.             cin>>num[i][j];
  30.         }
  31.     }
  32.     matSime(num);
  33.     return 0;
  34. }
  35.  
  36. int matSime(int M[tam_array])
  37. {
  38.  
  39.     for(k=0;k<fil;k++)
  40.     {
  41.         for(l=0;l<col;l++)
  42.         {
  43.             if(num[i][j] != num[j][i])
  44.             {
  45.                 es=false;
  46.             }
  47.         }
  48.     }
  49.     if(es==true)
  50.     {
  51.         cout<<"La matriz es simetrica.";
  52.     }
  53.     else
  54.     {
  55.         cout<<"La matriz no es simetrica.";
  56.     }
  57.     return num;
  58. }

El error está en matSime(num); pero no se porque :S

Muchas gracias chicos :D