I have this code, and I've generated an array of random number twice... Now, I just want to insert these numbers in to the vector upon execution.
I am using Microsoft Visual Studio.
This is my code:
using namespace std;
int main() {
int gRows, gCols;
std::cout << "Enter Rows: " << std::endl;
std::cin >> gRows;
std::cout << "Enter Cols: " << std::endl;
std::cin >> gCols;
std::vector<std::vector<int>> cGrid;
int numOfElem = gRows*gCols;
int* randNum = new int[numOfElem];
for (int x = 0; x < (numOfElem / 2); x++) {
srand((unsigned int)time(0));
const int fNum = rand() % 20 + 1; //generate num between 1 and 100
const int sNum = rand() % 20 + 1;
randNum[x] = fNum;
randNum[x + 2] = sNum;
}
for (int y = 0; y < numOfElem; y++) {
std::cout << randNum[y] <<std::endl;
}
//int i = 0;
for (int nRows = 0; nRows < gRows; nRows++) {// for every row and column
for (int nCols = 0; nCols < gCols; nCols++) {
cGrid[gRows][gCols] = 0;//card at that coordinate will be equal to
std::cout << cGrid[gRows][gCols];
//i = i + 1;
}
std::cout << std::endl;
}}