I do this program in c++. I want to build a table with random rows and 3 columns. When I compile there is no mistake but I execute the program do nothing and write nothing. Can you help me to find my error?
Thanks
int main(){
srand(time(0));
int project = (rand() % 5) + 1 ;
std::cout << "The Number is " << project << "." << std::endl;
vector<vector<int> > P(project, vector<int>(3));
for(int i = 0; i <= P.size(); ++i){
for(int j = 0;j <= P[i].size();++j){
P[i][j] = (rand() % 50)+10;
P[i][j] = (rand() % 2)+1;
P[i][j] = (rand() % 50)+1;
}
}
for(int a = 0;a <= P.size();++a){
for(int j = 0;j <= P[a].size();++j){
std::cout << "Project "<< a <<" :"<< P[a][j] ;
std::cout << P[a][j] <<" , ";
std::cout << P[a][j] <<" ."<< std::endl;
}
}
I get another problem it writes the same value for all the columns. So I need to change something in my loop right?