English
Source / code snippets

Shuffle-function / fortlaufende Zahlenreihen mix

 

RudiB.
Hi,

I steh straight fully on the Hose. I try a fortlaufen Zahlenreihe in a aray random To mix. Have there too what probiert, mere skin not really there.
CLS
Declare zaehler%,x%[],y%,worth%[]

While 0=0

    worth%[0]=1
    worth%[1]=2
    worth%[2]=3' Zahlenreihe 1-5
    worth%[3]=4
    worth%[4]=5
    y%=0
    x%[0]=0
    x%[1]=0
    x%[2]=0'aray-values on 0 settle
    x%[3]=0
    x%[4]=0
    zaehler%=4

    Whileloop 0,4

        'Print &loop

        Whileloop 300

            randomize
            y%=RND(&loop)

            If (y%>=0) and (y%<=4)

                If x%[y%]=0

                    x%[y%]=worth%[zaehler%]'new Wertzuweisung
                    Break

                EndIf

            Endif

        EndWhile

        dec zaehler%

    EndWhile

    whileloop 5

        print x%[&loop-1]

    EndWhile

    Print
    waitinput

Endwhile

waitinput

it'll In any drop not well mixed.....I seh well whom woods not sheer trees....an Shuffle-function (willkürlich mix give Yes not XProfan)...or ???
 
XProfan X4
Xprofan X4
Rudolf Beske / München

Hardware: NB Intel I9 - 16GByte RAM
04/21/21  
 




RudiB.
has itself Done....Have what in the baby-Box found and functions lovely.
Dim% 10
CLS
window 0,0-480,320
Declare i%,number%,x%
inc x%

Whileloop 7' 7 Durchläufe to that testing / look at

    clearlist
    Print
    Print "Durchgang..";x%
    inc x%
    Shuffle

Endwhile

Waitinput

Proc Shuffle

    Let i%=1

    While i%<10'list fill

        List% i%=i%
        Inc i%

    Wend

    Let i%=0
    Randomize

    While i%<9

        Let number%=List%(Rnd(10))

        If number%

            print number%,
            List% number%=0'Listenplatz null make
            Inc i%'

        EndIf

    EndWhile

ENDPROC

 
Xprofan X4
Rudolf Beske / München

Hardware: NB Intel I9 - 16GByte RAM
04/21/21  
 




RudiB.
Have the whole time verfeinert and a Shuffle.inc gebastelt.
herewith can fortlaufende Zahlenreihen random mixed go.
Also can one Startpunkt and a Schrittweite tuned go.

appeal:
shuffle 15,5,Test_Array%[],2,5

1.Parameter = Number of Zahlenelemente in the aray
2.Parameter = Number of items The random from this Zahlenreihe outputted go.
3. Parameter one leeres dynamisches INT-aray
4. Parameter = Startpunkt the Zahlenelemente z.B. 0 (0-1-2-3....)
5. Parameter = Schrittweite in the Zahlenelementreihe z.B. 5 (0-5-10-15...)

here couple code-Lines to that testing the INC
 $I Shuffle.inc
CLS
window 100,200 -800,400
Declare Test_Array%[],anzahl_elemente%,ausgabe_elemente%,Start_bereich%,Schrittweite%
' an example for Lottozahlen
anzahl_elemente%=49'49 numbers-items
ausgabe_elemente%=6'6 numbers from Zahlenfolge go mixed outputted.
start_bereich%=1'Startbereich = 1
Schrittweite%=1'Schrittweite = 1
shuffle anzahl_elemente%,ausgabe_elemente%,Test_Array%[],start_bereich%,Schrittweite%
Print "z.B: Lottozahlen 6 from 49"
spending
Print
' an example for a complete Zahlenreihe The mixed becomes.
anzahl_elemente%=20'20 numbers-items
ausgabe_elemente%=20'20 numbers from Zahlenfolge go mixed outputted.
start_bereich%=0'Startbereich = 0
Schrittweite%=1'Schrittweite = 1
shuffle anzahl_elemente%,ausgabe_elemente%,Test_Array%[],start_bereich%,Schrittweite%
Print "Ein Example for a complete Zahlenreihe The mixed becomes, with the Startpunkt 0"
spending
Print
' 15 numbers-items, 5 numbers go mixed outputted, Startpunkt = 2, Schrittweite = 5
shuffle 15,5,Test_Array%[],2,5
Print "15 numbers-items, 5 numbers go mixed outputted, Startpunkt = 2, Schrittweite = 5"
spending
Print
' 15 numbers-items, 8 numbers go mixed outputted, Startpunkt = 0, Schrittweite = 2
shuffle 30,8,Test_Array%[],0,2
Print "30 numbers-items, 8 numbers go mixed outputted, Startpunkt = 0, Schrittweite = 2"
spending
waitinput
End

Proc spending

    whileloop SizeOf(Test_Array%[])

        Print Test_Array%[&loop-1],

    EndWhile

    Print
    ArrDel Test_Array%[],0,SizeOf(Test_Array%[])-1'Arraygrösse becomes on 1 staid.

ENDPROC


it can also negatives values for Startpunkt and Schrittweite chosen go.

1 kB
Hochgeladen:04/22/21
Downloadcounter50
Download
 
Xprofan X4
Rudolf Beske / München

Hardware: NB Intel I9 - 16GByte RAM
04/22/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.356 Views

Untitledvor 0 min.
Gast.081510/03/24
Walter01/15/23
RudiB.09/02/22
N.Art07/21/22
More...

Themeninformationen

this Topic has 1 subscriber:

RudiB. (3x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie