Vectors



How would I write loop to initialize each element with the square root of the subscript?
1
2
3
4
5
const size_t N = 10;
std::vector<double> v;
v.reserve( N );

for ( size_t i = 0; i < N; i++ ) v.push_back( sqrt( ( double )i );
Topic archived. No new replies allowed.