It shouldn't be that difficult, I think.
Just create all the sequences first, eg:
#define N (10)
nh = N * 3 / 10;
np = N - nh;
char coins[N];
for (int i = 0;i < N;i++)
(i < nh) ? coins[i] = 'h' : coins[i] = 't';
Then swap randomly:
#define MAXSWAP 10
for (int i = 0;i < MAXSWAP;i++)
{
int top = <randomvalue>;
int bot = <randomvalue>;
swap(coins[top], coins[bot]);
}
Hope it does the trick.
KOkon.
|