![]() |
#32 |
Участник
|
Ещё один вариант...
![]() X++: BMRandom bmrandom = new bmRandom(); container a = ['a','b','c','d']; container b; int i,L,N; set result = new set(types::Container); set exception; int random(int _max) { int ret; ; ret = bmrandom.num(_max,1); if (exception.in(ret)) { ret = random(_max); } else { exception.add(ret); } return ret; } container fillcon() { container c; ; exception = new set(types::Integer); for (i = 1;i<=L;i++) { c=conins(c,conlen(c)+1,conpeek(a,random(L))); } return c; } ; L = conlen(a); N = factorial(L); result.add(a); info(con2str(a)); do { b = fillcon(); if(!result.in(b)) { result.add(b); info(con2str(b)); } } while (result.elements() < N); |
|