can anyone show me how to
display an apmatrix of random numbers on screen.
if not an apmatrix- how about a 2d array?
can anyone show me how to
display an apmatrix of random numbers on screen.
if not an apmatrix- how about a 2d array?
#include <iostream.h>
#include <time.h>
#include <apmatrix.h>
int main()
{
apmatrix <int> MyMatrix(10,10); //creates a 10 x 10 grid
srand(time(0)); //used for random numbers
int x,y;
for (x=0;x<MyMatrix.numrows();x++)
for (y=0;y<MyMatrix.numcols();y++)
MyMatrix[x][y] = rand()%10; //assigns random numbers 0-9
for (x=0;x<MyMatrix.numrows();x++)
{
for (y=0;y<MyMatrix.numcols();y++)
cout << MyMatrix[x][y];
cout << endl; //prints numbers as a grid instead of linearly
}
return(0);
}