Übungsaufgabe für alle :: Nr. 7 - Arrays und Zufall
Übersicht

![]() |
Alfadur |
![]() Antworten mit Zitat ![]() |
---|---|---|
erfüllt aber nicht die anforderungen, ist in etwa das gleiche problem wie bei kabelbinder... es können zahlen diagonal aneinandergrenzen die größere unterschiede als 1 haben ...
6 7 7 8 zb... das ist nicht erlaubt... |
||
A Cray is the only computer that runs an endless loop in less than four hours. |
![]() |
Ctuchik |
![]() Antworten mit Zitat ![]() |
---|---|---|
achso diagonal ist auch verboten, na dann, ich änder das schnell
Code: [AUSKLAPPEN] Graphics 800,600,0,2
SeedRnd MilliSecs() Dim feld(20,16) Global weight# = 0.3 ;Minimaler Wert ist -0.49, nach oben offen, aber mehr als 5.0 wenig sinnvoll) sx = Input("Start X: ") sy = Input("Start Y: ") feld(sx,sy) = 9 For number = 9 To 2 Step -1 .jump For xx=0 To 19 For yy=0 To 15 If feld(xx,yy) = number rep = False If yy < 15 If feld(xx,yy+1) = 0 Then feld(xx,yy+1) = number - WRand(weight#) : rep = True End If If yy > 0 If feld(xx,yy-1) = 0 Then feld(xx,yy-1) = number - WRand(weight#) : rep = True End If If xx < 19 If feld(xx+1,yy) = 0 Then feld(xx+1,yy) = number - WRand(weight#) : rep = True End If If xx > 0 If feld(xx-1,yy) = 0 Then feld(xx-1,yy) = number - WRand(weight#) : rep = True End If ;diagonal If yy < 15 And xx < 19 If feld(xx+1,yy+1) = 0 Then feld(xx+1,yy+1) = number - WRand(weight#) : rep = True End If If yy > 0 And xx > 0 If feld(xx-1,yy-1) = 0 Then feld(xx-1,yy-1) = number - WRand(weight#) : rep = True End If If xx < 19 And yy > 0 If feld(xx+1,yy-1) = 0 Then feld(xx+1,yy-1) = number - WRand(weight#) : rep = True End If If xx > 0 And yy < 15 If feld(xx-1,yy+1) = 0 Then feld(xx-1,yy+1) = number - WRand(weight#) : rep = True End If If rep Then Goto jump End If Next Next Next For xx=0 To 19 For yy=0 To 15 If feld(xx,yy) = 0 Then feld(xx,yy) = 1 Next Next For xx=0 To 19 For yy=0 To 15 Color 0,25*feld(xx,yy),0 Rect 45+xx*30,45+yy*20,30,20 Color 255,255,255 Text 50+xx*30,50+yy*20,feld(xx,yy) Next Next WaitKey() End Function WRand(w#) Return Sgn(Int(Rnd(0,1+w#))) End Function Sieht allerdings etwas unschön aus, weils manchmal nur diagonal zusammenhängt! |
||
Zu den Nebenwirkungen gehören trockener Mund, Übelkeit, Erbrechen, Harnstau, schmerzhafter rektaler Juckreiz, Halluzinationen, Demenz, Psychose, Koma, Tod und Mundgeruch!
Magie eignet sich nicht für alle! Fraget euren Arzt oder Apotheker! |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group