So I'm trying to create this program which randomly generates a 10 x 10 matrix of random integers from 0 - 2. The problem is the program always gives the same set of numbers. Here's the code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int mapDraw(int array[], int mapMax, int mapBound){
for(int i = 0; i <= (mapMax - 1); i++){
if((i % mapBound)==0){
cout << endl;
}
cout << array[i];
}
return 0;
}
int main(){
int mapx = 10;
int mapz = mapx;
int mapArea = mapx * mapz;
int store[mapArea];
for(int i = 0; i <= (mapArea -1); i++){
int height = rand() % 3;
store[i] = height;
}
mapDraw(store, mapArea, mapx);
return 0;
}
When I run the code it always gives me this:
2211210012
2210121200
0020110222
2020012110
2020020121
2210012011
1220011211
2020120002
0201021221
0021212002
For some reason it continues to give me the same out put after running the program multiple times. I would love some help and I have a hunch it will give you a different matrix when you run it on your machine so please try running it multiple times to see if the result is the same on consecutive runs. Thanks for the help in advance!