Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

select one random element of a vector in c++

vector<int> v{10,21,24,13};

int random = rand() % v.size();
int sel_elem = v[random];

cout<<"Selected Element: "<<sel_elem<<endl;
 
PREVIOUS NEXT
Tagged: #select #random #element #vector
ADD COMMENT
Topic
Name
3+6 =