Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[Problem] Random() szwankuje


Rekomendowane odpowiedzi

Opublikowano

dzień dobry!
otóż chodzi tu o to że random nie chce generować cyferki jeden(1)

oto kod:(nie pytaj do czego mi to)

i tak, tak wiem że to mogło zająć nie 300 tylko 100 linijek ale nie denerwuj się bo nie chce mi się myśleć na innowacyjnymi rozwiązaniami

 


Global $1 = 0
Global $2 = 0
Global $3 = 0
Global $4 = 0
Global $5 = 0
Global $6 = 0
Global $7 = 0
Global $8 = 0
Global $9 = 0
Global $10 = 0
Global $11 = 0
Global $12 = 0
Global $13 = 0
Global $14 = 0
Global $15 = 0
Global $16 = 0
Global $17 = 0
Global $18 = 0
Global $19 = 0
Global $20 = 0
Global $21 = 0
Global $22 = 0
Global $23 = 0
Global $24 = 0
Global $25 = 0
Global $26 = 0
Global $27 = 0
Global $28 = 0
Global $29 = 0
Global $30 = 0
Global $31 = 0
Global $32 = 0
Global $33 = 0
Global $34 = 0
Global $35 = 0
Global $36 = 0
Global $37 = 0
Global $38 = 0
Global $39 = 0
Global $40 = 0
Global $41 = 0
Global $42 = 0
Global $43 = 0
Global $44 = 0
Global $45 = 0
Global $46 = 0
Global $47 = 0
Global $48 = 0
Global $49 = 0
 
 
 
 
 
 
 
 
 
 
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\mikołaj\desktop\lotto gen form.kxf
$Form1_1 = GUICreate("Form1", 615, 288, 193, 125)
$Label1 = GUICtrlCreateLabel("1:", 8, 8, 13, 17)
$L1 = GUICtrlCreateLabel("GEN1", 32, 8, 33, 17)
$Label3 = GUICtrlCreateLabel("2:", 8, 32, 13, 17)
$L2 = GUICtrlCreateLabel("GEN2", 32, 32, 33, 17)
$Label5 = GUICtrlCreateLabel("3:", 8, 56, 13, 17)
$L3 = GUICtrlCreateLabel("GEN3", 32, 56, 33, 17)
$Label7 = GUICtrlCreateLabel("4:", 8, 80, 13, 17)
$L4 = GUICtrlCreateLabel("GEN4", 32, 80, 33, 17)
$Label9 = GUICtrlCreateLabel("5:", 8, 104, 13, 17)
$L5 = GUICtrlCreateLabel("GEN5", 32, 104, 33, 17)
$Label11 = GUICtrlCreateLabel("6:", 8, 128, 13, 17)
$L6 = GUICtrlCreateLabel("GEN6", 32, 128, 33, 17)
$Label13 = GUICtrlCreateLabel("7:", 8, 152, 13, 17)
$L7 = GUICtrlCreateLabel("GEN7", 32, 152, 33, 17)
$Label15 = GUICtrlCreateLabel("8:", 8, 176, 13, 17)
$L8 = GUICtrlCreateLabel("GEN8", 32, 176, 33, 17)
$Label17 = GUICtrlCreateLabel("9:", 8, 200, 13, 17)
$L9 = GUICtrlCreateLabel("GEN9", 32, 200, 33, 17)
$Label19 = GUICtrlCreateLabel("10:", 8, 224, 19, 17)
$L10 = GUICtrlCreateLabel("GEN10", 32, 224, 39, 17)
$Label21 = GUICtrlCreateLabel("11:", 120, 8, 19, 17)
$L11 = GUICtrlCreateLabel("GEN11", 152, 8, 39, 17)
$Label23 = GUICtrlCreateLabel("12:", 120, 32, 19, 17)
$L12 = GUICtrlCreateLabel("GEN12", 152, 32, 39, 17)
$Label25 = GUICtrlCreateLabel("13:", 120, 56, 19, 17)
$L13 = GUICtrlCreateLabel("GEN13", 152, 56, 39, 17)
$Label27 = GUICtrlCreateLabel("14:", 120, 80, 19, 17)
$L14 = GUICtrlCreateLabel("GEN14", 152, 80, 39, 17)
$Label29 = GUICtrlCreateLabel("15:", 120, 104, 19, 17)
$L15 = GUICtrlCreateLabel("GEN15", 152, 104, 39, 17)
$Label31 = GUICtrlCreateLabel("16:", 120, 128, 19, 17)
$L16 = GUICtrlCreateLabel("GEN16", 152, 128, 39, 17)
$Label33 = GUICtrlCreateLabel("17:", 120, 152, 19, 17)
$L17 = GUICtrlCreateLabel("GEN17", 152, 152, 39, 17)
$Label35 = GUICtrlCreateLabel("18:", 120, 176, 19, 17)
$L18 = GUICtrlCreateLabel("GEN18", 152, 176, 39, 17)
$Label37 = GUICtrlCreateLabel("19:", 120, 200, 19, 17)
$L19 = GUICtrlCreateLabel("GEN19", 152, 200, 39, 17)
$Label39 = GUICtrlCreateLabel("20:", 120, 224, 19, 17)
$L20 = GUICtrlCreateLabel("GEN20", 152, 224, 39, 17)
$Label41 = GUICtrlCreateLabel("21:", 240, 8, 19, 17)
$L21 = GUICtrlCreateLabel("GEN21", 272, 8, 39, 17)
$Label44 = GUICtrlCreateLabel("22:", 240, 32, 19, 17)
$L22 = GUICtrlCreateLabel("GEN22", 272, 32, 39, 17)
$Label46 = GUICtrlCreateLabel("23:", 240, 56, 19, 17)
$L23 = GUICtrlCreateLabel("GEN23", 272, 56, 39, 17)
$Label48 = GUICtrlCreateLabel("24:", 240, 80, 19, 17)
$L24 = GUICtrlCreateLabel("GEN24", 272, 80, 39, 17)
$Label50 = GUICtrlCreateLabel("25:", 240, 104, 19, 17)
$L25 = GUICtrlCreateLabel("GEN25", 272, 104, 39, 17)
$Label52 = GUICtrlCreateLabel("26:", 240, 128, 19, 17)
$L26 = GUICtrlCreateLabel("GEN26", 272, 128, 39, 17)
$Label54 = GUICtrlCreateLabel("27:", 240, 152, 19, 17)
$L27 = GUICtrlCreateLabel("GEN27", 272, 152, 39, 17)
$Label56 = GUICtrlCreateLabel("28:", 240, 176, 19, 17)
$L28 = GUICtrlCreateLabel("GEN28", 272, 176, 39, 17)
$Label58 = GUICtrlCreateLabel("29:", 240, 200, 19, 17)
$L29 = GUICtrlCreateLabel("GEN29", 272, 200, 39, 17)
$Label60 = GUICtrlCreateLabel("30:", 240, 224, 19, 17)
$L30 = GUICtrlCreateLabel("GEN30", 272, 224, 39, 17)
$Label62 = GUICtrlCreateLabel("31:", 360, 8, 19, 17)
$L31 = GUICtrlCreateLabel("GEN31", 392, 8, 39, 17)
$Label64 = GUICtrlCreateLabel("32:", 360, 32, 19, 17)
$L32 = GUICtrlCreateLabel("GEN32", 392, 32, 39, 17)
$Label66 = GUICtrlCreateLabel("33:", 360, 56, 19, 17)
$L33 = GUICtrlCreateLabel("GEN33", 392, 56, 39, 17)
$Label68 = GUICtrlCreateLabel("34:", 360, 80, 19, 17)
$L34 = GUICtrlCreateLabel("GEN34", 392, 80, 39, 17)
$Label70 = GUICtrlCreateLabel("35:", 360, 104, 19, 17)
$L35 = GUICtrlCreateLabel("GEN35", 392, 104, 39, 17)
$Label72 = GUICtrlCreateLabel("36:", 360, 128, 19, 17)
$L36 = GUICtrlCreateLabel("GEN36", 392, 128, 39, 17)
$Label74 = GUICtrlCreateLabel("37:", 360, 152, 19, 17)
$L37 = GUICtrlCreateLabel("GEN37", 392, 152, 39, 17)
$Label76 = GUICtrlCreateLabel("38:", 360, 176, 19, 17)
$L38 = GUICtrlCreateLabel("GEN38", 392, 176, 39, 17)
$Label78 = GUICtrlCreateLabel("39:", 360, 200, 19, 17)
$L39 = GUICtrlCreateLabel("GEN39", 392, 200, 39, 17)
$Label80 = GUICtrlCreateLabel("40:", 360, 224, 19, 17)
$L40 = GUICtrlCreateLabel("GEN40", 392, 224, 39, 17)
$Label82 = GUICtrlCreateLabel("41:", 480, 8, 19, 17)
$L41 = GUICtrlCreateLabel("GEN41", 512, 8, 39, 17)
$Label84 = GUICtrlCreateLabel("42:", 480, 32, 19, 17)
$L42 = GUICtrlCreateLabel("GEN42", 512, 32, 39, 17)
$Label86 = GUICtrlCreateLabel("43:", 480, 56, 19, 17)
$L43 = GUICtrlCreateLabel("GEN43", 512, 56, 39, 17)
$Label88 = GUICtrlCreateLabel("44:", 480, 80, 19, 17)
$L44 = GUICtrlCreateLabel("GEN44", 512, 80, 39, 17)
$Label90 = GUICtrlCreateLabel("45:", 480, 104, 19, 17)
$L45 = GUICtrlCreateLabel("GEN45", 512, 104, 39, 17)
$Label92 = GUICtrlCreateLabel("46:", 480, 128, 19, 17)
$L46 = GUICtrlCreateLabel("GEN46", 512, 128, 39, 17)
$Label94 = GUICtrlCreateLabel("47:", 480, 152, 19, 17)
$L47 = GUICtrlCreateLabel("GEN47", 512, 152, 39, 17)
$STARTBTN = GUICtrlCreateButton("S T A R T", 240, 256, 75, 25)
$Labellol = GUICtrlCreateLabel("48:", 480, 176, 19, 17)
$L48 = GUICtrlCreateLabel("GEN48", 512, 176, 39, 17)
GUICtrlCreateLabel("49:", 480, 200, 19, 17)
$L49 = GUICtrlCreateLabel("GEN49", 512, 200, 39, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
For $1 = 100000 To 1 Step -1
    $random = Random(0,49,1)
 
 
    Select
        Case $random = 1
            $1 = $1 + 1
        Case $random = 2
            $2 = $2 + 1
        Case $random = 3
            $3 = $3 + 1
        Case $random = 4
            $4 = $4 + 1
        Case $random = 5
            $5 = $5 + 1
        Case $random = 6
            $6 = $6 + 1
        Case $random = 7
            $7 = $7 + 1
        Case $random = 8
            $8 = $8 + 1
        Case $random = 9
            $9 = $9 + 1
        Case $random = 10
            $10 = $10 + 1
        Case $random = 11
            $11 = $11 + 1
        Case $random = 12
            $12 = $12 + 1
        Case $random = 13
            $13 = $13 + 1
        Case $random = 14
            $14 = $14 + 1
        Case $random = 15
            $15 = $15 + 1
        Case $random = 16
            $16 = $16 + 1
        Case $random = 17
            $17 = $17 + 1
        Case $random = 18
            $18 = $18 + 1
        Case $random = 19
            $19 = $19 + 1
        Case $random = 20
            $20 = $20 + 1
        Case $random = 21
            $21 = $21 + 1
        Case $random = 22
            $22 = $22 + 1
        Case $random = 23
            $23 = $23 + 1
        Case $random = 24
            $24 = $24 + 1
        Case $random = 25
            $25 = $25 + 1
        Case $random = 26
            $26 = $26 + 1
        Case $random = 27
            $27 = $27 + 1
        Case $random = 28
            $28 = $28 + 1
        Case $random = 29
            $29 = $29 + 1
        Case $random = 30
            $30 = $30 + 1
        Case $random = 31
            $31 = $31 + 1
        Case $random = 32
            $32 = $32 + 1
        Case $random = 33
            $33 = $33 + 1
        Case $random = 34
            $34 = $34 + 1
        Case $random = 35
            $35 = $35 + 1
        Case $random = 36
            $36 = $36 + 1
        Case $random = 37
            $37 = $37 + 1
        Case $random = 38
            $38 = $38 + 1
        Case $random = 39
            $39 = $39 + 1
        Case $random = 40
            $40 = $40 + 1
        Case $random = 41
            $41 = $41 + 1
        Case $random = 42
            $42 = $42 + 1
        Case $random = 43
            $43 = $43 + 1
        Case $random = 44
            $44 = $44 + 1
        Case $random = 45
            $45 = $45 + 1
        Case $random = 46
            $46 = $46 + 1
        Case $random = 47
            $47 = $47 + 1
        Case $random = 48
            $48 = $48 + 1
        Case $random = 49
            $49 = $49 + 1
    EndSelect
    Next
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $STARTBTN
            _display()
            msgbox(0,"",$1)
 
 
    EndSwitch
WEnd
 
 
 
Func _display()
        GUICtrlSetData($L1,$1)
        GUICtrlSetData($L2,$2)
        GUICtrlSetData($L3,$3)
        GUICtrlSetData($L4,$4)
        GUICtrlSetData($L5,$5)
        GUICtrlSetData($L6,$6)
        GUICtrlSetData($L7,$7)
        GUICtrlSetData($L8,$8)
        GUICtrlSetData($L9,$9)
        GUICtrlSetData($L10,$10)
        GUICtrlSetData($L11,$11)
        GUICtrlSetData($L12,$12)
        GUICtrlSetData($L13,$13)
        GUICtrlSetData($L14,$14)
        GUICtrlSetData($L15,$15)
        GUICtrlSetData($L16,$16)
        GUICtrlSetData($L17,$17)
        GUICtrlSetData($L18,$18)
        GUICtrlSetData($L19,$19)
        GUICtrlSetData($L20,$20)
        GUICtrlSetData($L21,$21)
        GUICtrlSetData($L22,$22)
        GUICtrlSetData($L23,$23)
        GUICtrlSetData($L24,$24)
        GUICtrlSetData($L25,$25)
        GUICtrlSetData($L26,$26)
        GUICtrlSetData($L27,$27)
        GUICtrlSetData($L28,$28)
        GUICtrlSetData($L29,$29)
        GUICtrlSetData($L30,$30)
        GUICtrlSetData($L31,$31)
        GUICtrlSetData($L32,$32)
        GUICtrlSetData($L33,$33)
        GUICtrlSetData($L34,$34)
        GUICtrlSetData($L35,$35)
        GUICtrlSetData($L36,$36)
        GUICtrlSetData($L37,$37)
        GUICtrlSetData($L38,$38)
        GUICtrlSetData($L39,$39)
        GUICtrlSetData($L40,$40)
        GUICtrlSetData($L41,$41)
        GUICtrlSetData($L42,$42)
        GUICtrlSetData($L43,$43)
        GUICtrlSetData($L44,$44)
        GUICtrlSetData($L45,$45)
        GUICtrlSetData($L46,$46)
        GUICtrlSetData($L47,$47)
        GUICtrlSetData($L48,$48)
        GUICtrlSetData($L49,$49)
    EndFunc

1375799776-U359635.jpg

Opublikowano

z tablicami mi się nie chce męczyć bo raz zadziała a raz nie

a tego to nie zauważyłem, dzięki

Nie znam przypadku zeby w dobrze napisanym kodzie tablice nie dzialaly ...

 

ps. zeby nie byc goloslownym to masz moj przyklad :

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $ile[101], $Label[101], $t
$Form1 = GUICreate("Losowanie liczb", 1129, 207, -1, -1)
GUISetFont(8, 400, 0, "Verdana")
$Button1 = GUICtrlCreateButton("Start", 8, 176, 75, 25, $WS_GROUP)
$Progress1 = GUICtrlCreateProgress(88, 177, 980, 22)
$Label1 = GUICtrlCreateLabel("100 %", 1080, 182, 41, 17)
For $i = 8 To 1016 Step 112
	For $r = 8 To 152 Step 16
		$t += 1
		$Label[$t] = GUICtrlCreateLabel($t & ".", $i, $r, 109, 17)
	Next
Next
GUISetState(@SW_SHOW)
WinSetOnTop($Form1, "", 1)
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			losuj()
	EndSwitch
WEnd
Func losuj()
	For $i = 1 To 100
		$ile[$i] = 0
	Next
	$end = 10000
	For $u = 1 To $end
		$a = Random(1, 100, 1)
		$ile[$a] += 1
		GUICtrlSetData($Label[$a], $a & ". -   " & $ile[$a])
		$obl = Floor($u / $end * 100)
		GUICtrlSetData($Progress1, $obl)
		GUICtrlSetData($Label1, $obl & " %")
	Next
EndFunc

 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...