I am trying to find transpose of 2D Matrix and want to create a function that take my 2D array and number of values of Matrix as input and return the transpose of a 2D Matrix . I have written the following code in C++
#include <iostream>
#include <string>
using namespace std;
//int** transpose(int arr[][] , int n);
int k=2;
int ** transpose(int wt[1][k] , int n )
{
int trans[n][1];
for(int i=0;i<n;i++)
{
trans[i][1] = wt[1][i];
}
return trans ;
}
int main()
{ int n;
cin >> n;
int wt_vect[1][n];
for( int i=0;i<n;i++)
{
wt_vect[1][i] = 0.7;
}
int trans[n][1] = transpose(wt_vect , n);
}
But getting error log as following
7:30: error: array bound is not an integer constant before ']' token 7:32: error: expected ')' before ',' token 7:34: error: expected unqualified-id before 'int'
Please help me to find transpose using Function . Thanks in Advance
Aucun commentaire:
Enregistrer un commentaire