Advertisement
s00rk

Sumar Matrices Ruben

Oct 17th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int F = 0, C = 0;
  7.     cout << "Total de Filas de las matrices: ";
  8.     cin >> F;
  9.     cout << "Total de Filas de las matrices: ";
  10.     cin >> C;
  11.     int matriz1[F][C];
  12.     int matriz2[F][C];
  13.     int matriz3[F][C*2];
  14.  
  15.     cout << "Ingresar los valores para la matriz 1" << endl;
  16.     for(int i = 0; i < F; i++)
  17.         for(int j = 0; j < C; j++)
  18.         {
  19.             cout << "Ingresa valor en la posicion [" << i << "," << j << "]: ";
  20.             cin >> matriz1[i][j];
  21.             matriz3[i][j] = matriz1[i][j];
  22.         }
  23.     cout << endl << "Ingresar los valores para la matriz 2" << endl;
  24.     for(int i = 0; i < F; i++)
  25.         for(int j = 0; j < C; j++)
  26.         {
  27.             cout << "Ingresa valor en la posicion [" << i << "," << j << "]: ";
  28.             cin >> matriz2[i][j];
  29.             matriz3[i][j+C] = matriz2[i][j];
  30.         }
  31.  
  32.     cout << endl << "Matriz 1" << endl;
  33.     for(int i = 0; i < F; i++)
  34.     {
  35.         for(int j = 0; j < C; j++)
  36.             cout << matriz1[i][j] << " ";
  37.         cout << endl;
  38.     }
  39.     cout << endl << "Matriz 2" << endl;
  40.     for(int i = 0; i < F; i++)
  41.     {
  42.         for(int j = 0; j < C; j++)
  43.             cout << matriz2[i][j] << " ";
  44.         cout << endl;
  45.     }
  46.  
  47.     cout << endl << "Suma [Matriz1+Matriz2]" << endl;
  48.     for(int i = 0; i < F; i++)
  49.     {
  50.         for(int j = 0; j < C*2; j++)
  51.             cout << matriz3[i][j] << " ";
  52.         cout << endl;
  53.     }
  54.     cin.get();
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement