This commit is contained in:
RafayAhmad7548 2024-06-16 18:53:25 +05:00
parent 37776af5db
commit ab03d5f10c
4045 changed files with 286212 additions and 3 deletions

View file

@ -0,0 +1,37 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,42 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
Matrix operator*(Matrix m){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,23 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
};
int main(){
return 0;
}

View file

@ -0,0 +1,26 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,52 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols, "multiplied");
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,28 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=rows;i<max;i++){
matrix[i] = new int[cols];
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,51 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
Matrix(3, 3);
return 0;
}

View file

@ -0,0 +1,81 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
Matrix(const Matrix& m) : rows(m.rows), cols(m.cols){
matrix = new int*[rows];
for(int i = 0; i < rows; ++i){
matrix[i] = new int[cols];
for(int j = 0; j < cols; ++j){
matrix[i][j] = m.matrix[i][j];
}
}
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
~Matrix(){
for(int i=0;i<rows;i++){
delete[] matrix[i];
}
delete matrix;
}
};
int main(){
Matrix m1(3, 2);
m1.input();
Matrix m2(2, 3);
m2.input();
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,79 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
Matrix(const Matrix& m) : rows(m.rows), cols(m.cols){
matrix = new int*[rows];
for(int i=0; i<rows;i++){
matrix[i] = new int[cols];
for(int j=0;j<cols;j++){
matrix[i][j] = m.matrix[i][j];
}
}
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
~Matrix(){
for(int i=0;i<rows;i++) delete[] matrix[i];
delete matrix;
}
};
int main(){
Matrix m1(3, 2);
m1.input();
Matrix m2(2, 3);
m2.input();
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,82 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
Matrix(const Matrix& m) : rows(m.rows), cols(m.cols) {
matrix = new int*[rows];
for(int i = 0; i < rows; ++i) {
matrix[i] = new int[cols];
for(int j = 0; j < cols; ++j) {
matrix[i][j] = m.matrix[i][j];
}
}
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
~Matrix(){
for(int i=0;i<rows;i++){
cout<<matrix[i]<<endl;
delete[] matrix[i];
}
delete matrix;
}
};
int main(){
Matrix m1(3, 2);
m1.input();
Matrix m2(2, 3);
m2.input();
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,26 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,19 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
};
int main(){
return 0;
}

View file

@ -0,0 +1,64 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
Matrix m1(3, 3);
m1.input();
Matrix m2(2, 3);
m2.input();
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,38 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,52 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,64 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
Matrix m1(3, 2);
m1.input();
Matrix m2(2, 3);
m2.input();
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,17 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
};
int main(){
return 0;
}

View file

@ -0,0 +1,13 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
int main(){
return 0;
}

View file

@ -0,0 +1,69 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
~Matrix(){
for(int i=0;i<rows;i++) delete[] matrix[i];
delete matrix;
}
};
int main(){
Matrix m1(3, 2);
m1.input();
Matrix m2(2, 3);
m2.input();
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,33 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,64 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
Matrix m1(3, 3);
Matrix m2(2, 3);
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,72 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
~Matrix(){
for(int i=0;i<rows;i++){
cout<<matrix[i]<<endl;
delete[] matrix[i];
}
delete matrix;
}
};
int main(){
Matrix m1(3, 2);
m1.input();
Matrix m2(2, 3);
m2.input();
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,52 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
Matrix operator*(Matrix m){
Matrix result(this->row, m.col, "multiplied");
for(int i=0;i<result.row;i++){
for(int j=0;j<result.col;j++){
int no = 0;
for(int x=0;x<this->col;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
return 0;
}

View file

@ -0,0 +1 @@
{"version":1,"resource":"file:///home/rafayahmad/Stuff/lab11/q3.cpp","entries":[{"id":"VhFA.cpp","timestamp":1713153300076},{"id":"uxIA.cpp","timestamp":1713153363776},{"id":"TRch.cpp","timestamp":1713153407013},{"id":"eoYF.cpp","timestamp":1713153418737},{"id":"InRu.cpp","timestamp":1713153454237},{"id":"2mzD.cpp","timestamp":1713153570230},{"id":"IjPz.cpp","timestamp":1713153623720},{"id":"6lVf.cpp","timestamp":1713153641904},{"id":"3MjE.cpp","timestamp":1713153655547},{"id":"hjOW.cpp","timestamp":1713153812181},{"id":"aKZa.cpp","timestamp":1713153822425},{"id":"00hf.cpp","timestamp":1713154229096},{"id":"MDaE.cpp","timestamp":1713154239806},{"id":"07EM.cpp","timestamp":1713154518676},{"id":"eRsg.cpp","timestamp":1713154825243},{"id":"6jvQ.cpp","timestamp":1713154839430},{"id":"O8xi.cpp","timestamp":1713154856931},{"id":"6uwT.cpp","timestamp":1713154879952},{"id":"rdtq.cpp","timestamp":1713154930677},{"id":"bYrr.cpp","timestamp":1713154946941},{"id":"kK88.cpp","timestamp":1713154991600},{"id":"Ky42.cpp","timestamp":1713155055866},{"id":"T8N2.cpp","timestamp":1713155486055},{"id":"WYhC.cpp","timestamp":1713155655786},{"id":"cvTh.cpp","timestamp":1713155848381},{"id":"EPAR.cpp","timestamp":1713156188303},{"id":"96Mj.cpp","timestamp":1713156218832},{"id":"9I82.cpp","timestamp":1713156317449},{"id":"lKUn.cpp","timestamp":1713161237501}]}

View file

@ -0,0 +1,19 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
};
int main(){
return 0;
}

View file

@ -0,0 +1,33 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
}
};
int main(){
return 0;
}

View file

@ -0,0 +1,63 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
Matrix m1(3, 3);
Matrix m2(2, 3);
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,79 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
}
Matrix(const Matrix& m) : rows(m.rows), cols(m.cols){
matrix = new int*[rows];
for(int i=0; i<rows;i++){
matrix[i] = new int[cols];
for(int j=0;j<cols;j++){
matrix[i][j] = m.matrix[i][j];
}
}
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
~Matrix(){
for(int i=0;i<rows;i++) delete[] matrix[i];
delete matrix;
}
};
int main(){
Matrix m1(3, 2);
m1.input();
Matrix m2(2, 3);
m2.input();
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,63 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
int rows;
int cols;
int **matrix;
public:
Matrix(int rows, int cols) : rows(rows), cols(cols){
matrix = new int*[rows];
for(int i=0;i<rows;i++) matrix[i] = new int[cols];
input();
}
void input(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
void print(){
cout<<"Enter values: ";
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
cin>>matrix[i][j];
}
}
}
Matrix operator*(Matrix m){
Matrix result(this->rows, m.cols);
for(int i=0;i<result.rows;i++){
for(int j=0;j<result.cols;j++){
int no = 0;
for(int x=0;x<this->cols;x++){
no += this->matrix[i][x]*m.matrix[x][j];
}
result.matrix[i][j] = no;
}
}
return result;
}
};
int main(){
Matrix m1(3, 3);
Matrix m2(2, 3);
Matrix m3 = m1*m2;
m3.print();
return 0;
}

View file

@ -0,0 +1,17 @@
/*
Rafay Ahmad
23I-2526
*/
#include <iostream>
using namespace std;
class Matrix{
};
int main(){
return 0;
}