![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5
![]() |
problem with reading my matrices
I am trying to write a program that will do the followings:
Addition of two matrices Subtraction of two matrices Multiplication of two matrices Inverse of a matrix Up too now I have defined my class but I have some problem with reading my matrices, I would appreciate your help, I can’t understand exactly what am I doing or what am I suppose to do: Please let me know if I am on the right path: #include <iostream>
#include <stdlib.h>
using namespace std;
//---------------------------------------------------------------//
class matrix{
public:
matrix();
void readmatrix();
void printmatrix();
bool addsub(char c, const matrix &A, const matrix &B);
private:
void identity();
int row, col;
float entryA[maxrow][maxcol];
float entryB[maxrow][maxcol];
float answer[maxrow][maxcol];
};
//------------------------------------------------------//
void matrix::readmatrix()
cout << "Enter number of rows for Matrix A:" <<endl;
cin >> rowa;
cout << "Enter number of col for Matrix A:" <<endl;
cin >> cola;
cout << "Enter the elements of Matrix A:" <<endl;
for (i=0;i<rowa;i++)
{
for (j=0;j<cola;j++)
{
cin >> entryA[row][col];
}
}
cout << "Enter number of rows for Matrix B:" <<endl;
cin >> rowb;
cout << "Enter number of col for Matrix B:" <<endl;
cin >> colb;
cout << "Enter the elements of Matrix B:" <<endl;
for (i=0;i<rowb;i++)
{
for (j=0;j<colb;j++)
{
cin >> entryB[row][col];
}
}
//----------------------------------------------------//Also do I need to define all these arrays?since I am having two D Arrays. float entryA[maxrow][maxcol];
float entryB[maxrow][maxcol];
float answer[maxrow][maxcol];Thanks
__________________
Personal Portfolio TecBrain Support Forum Linux VS Windows ... Dont Even Think of it .. Distribution: Slackware if (OS==Linux) return success There are 10 kinds of people, those who can read binary numbers and those who can't. Last edited by TecBrain; Feb 26th, 2005 at 4:51 PM. Reason: Progress// |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 5
![]() |
Is it possible to change the title name?
__________________
Personal Portfolio TecBrain Support Forum Linux VS Windows ... Dont Even Think of it .. Distribution: Slackware if (OS==Linux) return success There are 10 kinds of people, those who can read binary numbers and those who can't. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|