MAX 까지의 중복되지 않는 난수를 생성할때 이와 같은 방법을 사용한다.

cnt = MAX;
for (i = 0; i < MAX; i++)
    n[i] = i;
for (j = 0; j < loop_cnt; j++) {
    swap(n[rand() % cnt], n[--cnt]);
    printf("%d", n[cnt]);
}

출처 : http://kldp.org/node/73442