Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how creat matrix column in c++

#include <iostream>

using namespace std;

template <int rows, int cols>
void display(int (&array)[rows][cols]) {
  int i, j;
  cout<<"
";
  for(i = 0; i<rows; i++) {
      for(j = 0; j<cols; j++) {
        cout<<" ";
        cout<<array[i][j];
      }
      cout<<"
";
    }
}


int main() {
  int M1[3][3];
  cout<<"Enter your matrix elements: 
";
  int i, j;
    for(i = 0; i<3; i++) {
      for(j = 0; j<3; j++) {
        cout<<"a["<<i<<"]["<<j<<"]: ";
        cin>>M1[i][j];
      }
    }
    display(M1);
  return 0;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #creat #matrix #column
ADD COMMENT
Topic
Name
4+2 =