Хаос-пример на JAVA
import java.util.*
; public class Chaos
{public static void main
( String[]args
){String name="67890VDKT"
; System.out.println( name)
; System.out.println
( new Chaos( 1234L).get( name)
) // K60897VTD
; int len=name.length()
; StringBuffer sB=new StringBuffer()
; for ( int i
:new Chaos( 1234L).get( len)
) sB.append
( name.charAt( i)
)
; System.out.println
( sB.toString()
) // K60897VTD
;}
private Random random=null
//__________
; public Chaos
(
){random=new Random()
;}
public Chaos
( long seed
){random=new Random( seed)
;}
//__________
public String get // for Windows
( String s
){int i=0
, len=s.length()
; byte[]bytes=s.getBytes()
; int[]events=new int[len]
; events[0]=random.nextInt()
; while ( ++i<len
){events[i]=random.nextInt()
; if ( events[i-1]<=events[i]
) continue
; int j=i
; do {int k=events[j]
; events[j]=events[j-1]
; events[j-1]=k
; byte b=bytes[j]
; bytes[j]=bytes[j-1]
; bytes[j-1]=b
;}
while ( --j>0
&&events[j-1]>events[j]
)
;}
return new String( bytes)
;}
public int[]get
( int len
){int i=0
; int[]ints=new int[len]
, events=new int[len]
; ints[0]=0
; events[0]=random.nextInt()
; while ( ++i<len
){ints[i]=i
; events[i]=random.nextInt()
; if ( events[i-1]<=events[i]
) continue
; int j=i
; do {int k=events[j]
; events[j]=events[j-1]
; events[j-1]=k
; k=ints[j]
; ints[j]=ints[j-1]
; ints[j-1]=k
;}
while ( --j>0
&&events[j-1]>events[j]
)
;}
return ints
;}
}
28.07.2008г. А.Таракановский