C++ Question

Discussion in 'Programming' started by texanweb, Feb 11, 2008.

  1. #1
    If A and B are two m x n matrices, their sim is define as follows: If Aij and Bij are the entire's in the ith row and jth column of A and B, respectively, then Aij + Bij is the entry on the ith row and jth column of their sum, which will also be an m x n matrix. Write a program to read two m x n matrices, display them, and calculate and display their sum.


    This is what I have as of right now. I have display them, but I am stuck on the calculation part. Does anybody know what I should do next?


    
    #include <iostream>
    #include <iomanip>
    
    using namespace std;
    
     void fill(int**p, int rowSize, int columnSize);
     void print(int**p, int rowSize, int columnSize);
    
     int main()
     {
      int **board;
    
      int rows;
      int columns;
    
      cout << "Enter the number of rows and colums: ";
      cin >> rows >> columns;
      cout << endl;
    
      // Create the rows of board
      board = new int* [rows];
    
      //Create the colums of board
      for (int row = 0; row < rows; row++)
       board[row] = new int[columns];
    
      //Insert elements into board
      fill(board, rows, columns);
    
      cout <<"Board:" << endl;
    
      //Output the elements of board
      print(board, rows, columns);
    
            system("PAUSE");
            return EXIT_SUCCESS;
     }
    
     void fill(int **p, int rowSize, int columnSize)
     {
      for (int row = 0; row < rowSize; row++)
      {
       cout << "Enter " << columnSize << " number(s) for row number " << row << ": ";
       for (int col = 0; col < columnSize; col++)
        cin >> p[row][col];
       cout << endl;
    
      }
     }
     
     void print(int **p, int rowSize, int columnSize)
     {
      for (int row = 0; row < rowSize; row++)
      {
       for (int col = 0; col < columnSize; col++)
        cout << setw(5) << p[row][col];
       cout << endl;
      }
     }
    
    Code (markup):
     
    texanweb, Feb 11, 2008 IP
  2. sasta_king

    sasta_king Banned

    Messages:
    147
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hey
    i can make this.. bt u gotta pay me if you need assistance
    wat say.. am good in c,c++..
     
    sasta_king, Feb 12, 2008 IP