Generate Random List with no Repeat Values

Here's a question that I see lots of posts on. The posts that I have read tend to be mostly focused on efficiency at the expense of being quite confusing.

Let's say that I want a list 10 of integers from 1 through 10, but I want that list to be in random order. I could start like this:

int c[10];
for (int i = 1; i <= 10; i++)
c[i] = i;

That would put them in ascending order, but what if I wanted them to be in random order? Is there a relatively simple way to do this? I'm not that worried about efficiency. I'm more interested in simplicity.

Thanks.
See http://www.cplusplus.com/reference/algorithm/random_shuffle/
Note that this is not specific to vectors and other containers. You can pass two pointers for iterators.
Thanks very much. This is one of the posts that I looked at. Template classes confuse the crap out of me. I'd rather do this with an algorithm, if you know of one.
Topic archived. No new replies allowed.