Hola pues ya para concluir con la secci贸n de programas en C++ les ofrezco este, es un programa que suma y resta matrices en C++.

En teor铆a se hace as铆 (suma):

y el c贸digo es este

C++:
  1. #include <iostream.h>
  2. #include <stdlib.h>
  3.  
  4. int operacion(int [][100], int [][100], int [][100], int , int , int, int, int);
  5.  
  6. int main()
  7. {
  8.   int n,f,c,r,f1,f2,c1,c2, m1[100][100], m2[100][100], mr[100][100];
  9.   cout<<"1  --  Sumar"<<endl<<"2  --  Restar"<<endl<<"Otro numero  --  Salir"<<endl; cin>>n;
  10.   while ((n>0) && (n<3))
  11.     {
  12.      f1=0; c1=0; f2=0; c2=0;
  13.      while ((f1<1) || (f1>101))
  14.       { cout<<"Introduce las filas de la matriz 1 [1-100]: "; cin>>f1; }
  15.      while ((c1<1) || (c1>101))
  16.       { cout<<"Introduce las columnas de la matriz 1 [1-100]: "; cin>>c1; }
  17.  
  18.      for (f=0; f<=f1; f++)
  19.       {
  20.        for (c=0; c<=c1; c++)
  21.          { cout<<"m1["<<f<<"]["<<c<<"] = "; cin>>m1[f][c]; }
  22.       }
  23.  
  24.      while ((f2<1) || (f2>101))
  25.       { cout<<endl<<"Introduce las filas de la matriz 2 [1-100]: "; cin>>f2; }
  26.      while ((c2<1) || (c2>101))
  27.       { cout<<"Introduce las columnas de la matriz 2 [1-100]: "; cin>>c2; }
  28.  
  29.      for (f=0; f<=f2; f++)
  30.       {
  31.        for (c=0; c<=c2; c++)
  32.          { cout<<"m2["<<f<<"]["<<c<<"] = "; cin>>m2[f][c]; }
  33.       }
  34.  
  35.      r=operacion(m1,m2,mr,n,f1,f2,c1,c2);
  36.      if (r==-1) cout<<endl<<"No se pudo realizar la operacion ya que el tama帽o de las matrices no coincide";
  37.      else
  38.        {
  39.         for (f=0; f<=f2; f++)
  40.           {
  41.            for (c=0; c<=c2; c++)
  42.              cout<<"  "<<mr[f][c]<<"  ";
  43.            cout<<endl;
  44.           }
  45.        }
  46.      cout<<endl<<"1  --  Sumar"<<endl<<"2  --  Restar"<<endl<<"Otro numero  --  Salir"<<endl; cin>>n;
  47.     }
  48.   cout<<endl<<"Fin de programa..."<<endl;
  49.   system("PAUSE");
  50.   return 0;
  51. }
  52.  
  53. int operacion(int m1[][100], int m2[][100], int mr[][100], int n, int f1, int f2,int c1, int c2)
  54. {
  55.   int f,c;
  56.   if ((f1==f2) && (c1==c2)) //si si se pueden sumar/restar
  57.     {
  58.      if (n==1) //suma
  59.        {
  60.         for (f=0; f<=f1; f++)
  61.          {
  62.           for (c=0; c<=c1; c++)
  63.             mr[f][c] = m1[f][c] + m2[f][c];
  64.          }
  65.        }
  66.      else  //resta
  67.        {
  68.         for (f=0; f<=f1; f++)
  69.          {
  70.           for (c=0; c<=c1; c++)
  71.             mr[f][c] = m1[f][c] - m2[f][c];
  72.          }
  73.        }
  74.      return 1;
  75.     }
  76.   else
  77.     {return -1;}
  78. }



Saludos!