//
// Matrix reading from stdin
//
#include <iostream>
#include <stdlib.h>
using namespace std;


int
main (int argn, char *argv[])
{
  int dim1 = 2, dim2 = 2;

  if (argn == 3)
    {
      // Get arguments passed in the line command
      dim1 = atoi (argv[1]);
      dim2 = atoi (argv[2]);
    }
  else
    {
      // Read matrix dimensions
      cout << "Enter the number of rows: ";
      cin >> dim1;
      cout << "Enter the number of columns: ";
      cin >> dim2;
    }

  // 2-dimenstions matrix definition
  int M[dim1][dim2];

  // Double cycle to read each element
  for (int i = 0; i < dim1; i++)
    for (int j = 0; j < dim2; j++)
      {
	cout << "M[" << i << "][" << j << "] = ";
	cin >> M[i][j];
      }

  return 0;
}

