const int MAX = 13;
int a[MAX];
for (int i = 0; i < MAX; ++i) a[i] = i;
for (int i = 0; i < MAX; ++i) {
int r = rand() % MAX;
while(r == i) r = rand() % MAX;
int t = a[i]; a[i] = a[r]; a[r] = t;
}
That oughta take care of the first thing. ;D Shuffling the same elements twice is something that has in chance in real life as well, so it's part of being random. :)