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 :: Function to calculate compound interest in C++ 
Cpp :: 31. Next Permutation leetcode solution in c++ 
Cpp :: vector of vectors of pairs c++ 
Cpp :: check even or odd c++ 
Cpp :: c++ reverse part of vector 
Cpp :: c++ remove chars from string 
Cpp :: c++ set swap 
Cpp :: how to replace part of string with new string c++ 
Cpp :: how to find even and odd numbers in c++ 
Cpp :: heap buffer overflow in c 
Cpp :: passing custom function in sort cpp 
Cpp :: opencv c++ feature detection 
Cpp :: how to sort array in c++ stockoverflow 
Cpp :: vector from angle 
Cpp :: c++ fill two dimensional array 
Cpp :: oncomponentendoverlap ue4 c++ 
Cpp :: cpp oop 
Cpp :: c++ unittest in ros 
Cpp :: how to format big numbers with commas in c++ 
Cpp :: google test assert exception 
Cpp :: lists occurrences of characters in the string c++ 
Cpp :: if else in c++ 
Cpp :: c++ memset 
Cpp :: cpp undefined reference to function 
Cpp :: queue operations c++ 
Cpp :: valid parentheses in c++ 
Cpp :: flutter text direction auto 
Cpp :: pause the console c++ 
Cpp :: char input in c++ 
Cpp :: progress indicator raytracer 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =