int a[N]={1,2,...,N}; for(int i = N; i > 0; --i) { tmp = rand() % i; t = a[tmp]; a[tmp] = a[i-1]; a[i-1] = t; }