quick question

I am trying to use an array of a size that will be determined by the user, therefore I must use a vector, right?

In class I was told that this is how I call a vector:
vector <int> x;

Is the vector called vector? Is it called x?

Can I do this?
1
2
3
4
5
for(int i=0;i<=10;i++)
{

cout<<x[i];
}	


Can someone point me to some basic ways of implementing a vector? I have no idea how it works or how I can do anything with it. Thank you so much!
closed account (o3hC5Di1)
Hi there,

Your assumptions are correct. This here seems like a decent tutorial to get started with std::vector:
http://www.dreamincode.net/forums/topic/33631-c-vector-tutorial/

All the best,
NwN
Thank you so much!!! I'm doing a multidimensional NxN vector. I have to ask the user how big he wants his matrix, then make sure there is only one element per row and column and diagonal, and give the number of solutions. (N-queens problem)

I have defined my multidimensional vector. Can you tell me if my following logic makes sense?

1- Make the [0][0] position be equal to 1. //1 will be "occupied by element or something already in the column/row/diagonal".

2- Make [0][0 to n] = to 1, make [0 to n][0] = to 1, as well as find some way to write the diagonals.

3- Check all elements to find the next element == to 0. If there is one, repeat step 1-2 until there is no possible solution. When there is no possible queen to place, compare n to the amount of queens. If it's equal, count up a solution. If it's not equal, backtrack until you find a solution.

Am I right? Am I missing something?
Topic archived. No new replies allowed.