1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include "stdafx.h"
#include <iostream>
#include <vector>
#include "Function_Declare.h"
using namespace std;
float& Display_Individual_Elements(vector<float> *,int, int);
int main(){
int m1, n1, m2, n2;
cout<<"Enter the dimension of first matrix \n";
cin>>m1>>n1;
// Declaring matrix of size (m x n)
vector<vector<float>> A(m1, vector<float>(n1,0));
//Display_Individual_Elements(A, m1, n1);
cout<<"Enter the dimension of second matrix \n";
cin>>m2>>n2;
// Declaring matrix of size (m2 x n2)
vector<vector<float>> B(m2, vector<float>(n2,0));
vector<vector<float>> *ptrB;
ptrB = &B;
int i, j;
for (i=1;i<=m2;i++){
for (j=1;j<=n2;j++){
Display_Individual_Elements(ptrB, i, j);
}
}
system("pause");
return 0;
}
float& Display_Individual_Elements(vector<vector<float>> *p, int m, int n)
{
cout << p->at(m).at(n) << endl;
}
|