Search
 
SCRIPT & CODE EXAMPLE
 

CPP

create matrix cpp

typedef std::vector<std::vector<double> > Matrix;
//with initialization
Matrix matrix1 = { {0.1,1.1,.2},
                 {.4,.5,.6}, 
                 {.8,.9,.10}
                };
//just initiation (3x3)
Matrix matrix2(3, std::vector<double>(3) );
Comment

matrix c++

void matrixInput(int n, int m, int **arr)
{
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> arr[i][j];
    }
  }
}

void matrixDisplay(int n, int m, int **arr)
{

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cout << arr[i][j] << " ";
    }
    cout << endl;
  }
}

void matrix()
{
  int n, m;
  cout << "Enter matrix row and column: ";
  cin >> n >> m;

  int **arr;
  arr = new int *[m];
  for (int i = 0; i < m; i++)
    arr[i] = new int[m];

  matrixInput(n, m, arr);
  cout << "
Displaying matrix: 
";
  matrixDisplay(n, m, arr);
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: full implementation of binary search tree in C++ 
Cpp :: cpp vscode multipe compilation 
Cpp :: cmd color text c++ 
Cpp :: c++ json parser euc-kr 
Cpp :: rethrow exception c++ 
Cpp :: C++ cout iostream 
Cpp :: how to print items in c++ 
Cpp :: c++ pop string from vector 
Cpp :: how to increase array memory in c++ 
Cpp :: opencv(4.5.1) c:usersappveyorappdatalocal emp1pip-req-build-kh7iq4w7opencvmodulesimgprocsrc esize.cpp:4051: error: (-215:assertion failed) !ssize.empty() in function 
Cpp :: closing a ifstream file c++ 
Cpp :: what is throw in c++ 
Cpp :: shortest path in unweighted graph bfs 
Cpp :: Split a number and store it in vector 
Cpp :: erase range vector c++ 
Cpp :: shift element to end of vector c++ 
Cpp :: options select from array 
Cpp :: array of charcter c++ 
Cpp :: assign value to a pointer 
Cpp :: Implicit conversion casting 
Cpp :: c++ constructor 
Cpp :: c++ map vector as keys 
Cpp :: c++ include difference between quotes and brackets 
Cpp :: store arbitrarly large vector of doubles c++ 
Cpp :: subtraction of a 2d matrix in c++ 
Cpp :: c create 1 bit value 
Cpp :: the number of ones int bitset 
Cpp :: argsort c++ 
Cpp :: c++ argument list for class template is missing 
Cpp :: and condtion c++ 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =