Thank you for your helpful answerIts necessary for you to pa

Thank you for your helpful answer!(It\'s necessary for you to pay attention to the given information)
8. (10 pts) Let us define a new data type Matrix for representing 2-dimensional (extendable) array of float type using STL vector as shown below. A m-by-n matrix A is called \"skew symmetric\" if A is a square matrix (ie, m== n) and A[i][j] ==-AU][i] for all i *) Compose an efficient function for checking if A is skew symmetric (i.e. return true if A is skew symmetric, and false otherwise). Note that data is stored at Alilül for i0.m-1, j-0.n-1. You also need to fill in the parameter list of the function in an efficient way. typedef vectorvector Matrix: bool checkSkewSymmetric

Solution

#include<iostream>
#include<vector>
using namespace std;
typedef vector<vector<float>> Matrix;
void main()
{
int a[10][10],i,j,m,n;
Matrix x;
vector<float> y;

bool checkSkewSymmetric(Matrix m,int);
cout<<\"Enter order of square matrix: \";
cin>>m;
//Enter values for matrix
for(i=1;i<=m;i++)
{
   vector<float> temp;
   for(j=1;j<=m;j++)
   {
       cout<<\"Enter value of a[\"<<i<<\"]\"<<\"[\"<<j<<\"]:\"<<endl;
       cin>>n;
       temp.push_back(n);
      
   }
   x.push_back(temp);
  
}

//print matrix
cout<<\"Elements ofmatrix: \";
for(i=0;i<m;i++)
{
   cout<<endl;
   for(j=0;j<m;j++)
   {
   cout<<x[i][j]<<\"\\t\";
   }
}

bool result;
result = checkSkewSymmetric(x,m);
if(result)
{
   cout<<\"\ Matrix is skew symmetric\ \";
}
else
   cout<<\"\ Matrix is not skew symmetric\ \";

}

bool checkSkewSymmetric(Matrix a,int m)
{
   for(int i=0;i<m;i++)
   {
   for(int j=0;j<m;j++)
   {
   if(a[i][j]!=-a[j][i])
   {
  
       return false;
   }
   }
   }

   return true;

}

Thank you for your helpful answer!(It\'s necessary for you to pay attention to the given information) 8. (10 pts) Let us define a new data type Matrix for repre
Thank you for your helpful answer!(It\'s necessary for you to pay attention to the given information) 8. (10 pts) Let us define a new data type Matrix for repre

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site