Hi All,
I am new to C++, I am tring to generate the random number from 0-99, and save it to a matrix array with the size of 10x10.
Below is my code, the resule comes out funny. Can you help to see what goes wrong?
#include<stdio.h> //Header file
#include<stdlib.h>
#include<time.h>
#include<iostream>
using namespace std;
#define MAXROWS 10 //Define max rows =20
#define MAXCOLS 10 //Define max cols =30
int main()
{
int random_matrix[MAXROWS][MAXCOLS];
int i;
int j;
/* initialize random seed: */
srand(static_cast<unsigned>(time(0)));
/* generate number: */
for (i=0;i<MAXROWS;i++)
{
for (j=0;j<MAXCOLS;j++)
random_matrix[i][j]= rand() % 100;
cout << random_matrix[i][j] << endl; //display table
}
system("pause");
}