Page 1 sur 1

Code plus ou moins

Message non luPosté: 17 Fév 2020, 19:50
de sangokuhomer
Code: Tout sélectionner
Lbl 11
Menu("+OU-","1JOUEUR",1,"2JOUEURS",2,"QUITTEZ",3
Lbl 1
Input "NBR MIN  ",A
Input "NBR MAX  ",B
Input "NBR CHANCES  ",K
K+1→K
K-1→K
nbrAléatEnt(A,B)→H
EffÉcran
0→E
While A≠H
Lbl 8
E+1→E
Input "1NBR:",A
K-1→K
If K=0
Then
If A=H
Then
Disp "GG"
Disp "NBR D ESSAIS:"
Disp E
Pause
Goto 11
End
Disp "PERDU"
Disp "LE NBR ETAIT"
Disp H
Pause
Goto 11
End
If K<0
Then
Goto 9
End
If A<H
Then
Disp "+"
Disp "NBR DE COUP"
Disp K
Goto 8
End
If A>H
Then
Disp "-"
Disp "NBR DE COUP"
Disp K
Goto 8
End
If A=H
Then
Disp "GG"
Disp "NBR D ESSAIS:"
Disp E
Pause
Goto 11
Lbl 2
Input "NOM J1  ",Chn1
Input "NOM J2  ",Chn2
Input "NBR MIN  ",A
Input "NBR MAX  ",B
Input "NBR COUP J1  ",S
Input "NBR COUP J2  ",T
S+1→S
S-1→S
T+1→T
T-1→T
nbrAléatEnt(A,B)→C
nbrAléatEnt(A,B)→E
EffÉcran
0→Y
0→X
Lbl 10
Y+1→Y
If S<0
Then
Disp "ERREUR"
Goto 14
End
Input "1NBR J1  ",D
S-1→S
If S=0 et D=C
Then
Disp "GG"
Disp Chn1
Disp "TU AS GAGNE"
Disp "TU ES PREMIER"
Disp "NBR ESSAI"
Disp Y
Pause
Goto 11
End
If S=0
Then
Disp "PERDUE"
Disp "LE NBR ETAIT"
Disp C
Goto 14
End
If D=C
Then
Disp "GG"
Disp Chn1
Disp "TU AS GAGNE"
Disp "TU ES PREMIER"
Disp "NBR ESSAI"
Disp Y
Pause
Goto 11
End
If D<C
Then
Disp "+"
Disp "NBR DE COUP"
Disp S
Goto 12
End
If D>C
Then
Disp "-"
Disp "NBR DE COUP"
Disp S
Goto 12
End
Lbl 12
X+1→X
Input "1NBR J2  ",F
T-1→T
If T<0
Then
Disp "ERREUR"
Goto 15
End
If T=0 et F=E
Then
Disp "GG"
Disp Chn2
Disp "TU AS GAGNE"
Disp "TU ES PREMIER"
Disp "NBR ESSAI"
Disp X
Pause
Goto 11
End
If T=0
Then
Disp "PERDUE"
Disp "LE NBR ETAIT"
Disp E
Goto 15
Pause
End
If F=E
Then
Disp "GG "
Disp Chn2
Disp "TU AS GAGNE"
Disp "TU ES PREMIER"
Disp "NBR ESSAI"
Disp X
Pause
Goto 11
End
If F<E
Then
Disp "+"
Disp "NBR DE COUP"
Disp T
Goto 10
End
If F>E
Disp "-"
Disp "NBR DE COUP"
Disp T
Goto 10
End
Lbl 14
X+1→X
Input "1NBR J2  ",F
T-1→T
If T<0
Then
Disp "ERREUR"
Goto 11
End
If T=0 et F=E
Then
Disp "GG"
Disp Chn2
Disp "TU AS GAGNE"
Disp "TU ES PREMIER"
Disp "NBR ESSAI"
Disp X
Pause
Goto 11
End
If T=0
Then
Disp "PERDUE"
Disp "LE NBR ETAIT"
Disp E
Goto 11
Pause
End
If F<E
Then
Disp "+"
Disp "NBR DE COUP"
Disp T
Goto 14
End
If F>E
Then
Disp "-"
Disp "NBR DE COUP"
Disp T
Goto 14
End
If F=E
Then
Disp "GG"
Disp Chn2
Disp "TU AS GAGNE"
Disp "TU ES PREMIER"
Disp "NBR ESSAI"
Disp X
Pause
Goto 11
End
Lbl 15
Y+1→Y
Input "1NBR J2  ",D
S-1→S
If S<0
Then
Disp "ERREUR"
Goto 11
End
If S=0 et D=C
Then
Disp "GG"
Disp Chn1
Disp "TU AS:GAGNE"
Disp "TU ES PREMIER"
Disp "NBR ESSAI"
Disp Y
Pause
Goto 11
End
If S=0
Then
Disp "PERDUE"
Disp "LE NBR ETAIT"
Disp C
Goto 11
Pause
End
If D<C
Then
Disp "+"
Disp "NBR DE COUP"
Disp S
Goto 15
End
If D>C
Then
Disp "-"
Disp "NBR DE COUP"
Disp S
Goto 15
End
If D=C
Then
Disp "GG"
Disp Chn1
Disp "TU AS GAGNE"
Disp "TU ES PREMIER"
Disp "NBR ESSAI"
Disp Y
Pause
Goto 11
End
Lbl 3
End

Re: Code plus ou moins

Message non luPosté: 17 Fév 2020, 20:10
de Hamza.S
Évite les Goto Lbl dans les boucles et conditions, ça crée une fuite de mémoire.
Pourquoi K+1->K:K-1->K ? Je ne comprends pas l'utilité, tu as fais pareil pour S et T plus bas.
If lorsqu'il y a qu'une instruction pas besoin de Then.
Goto suivi de Pause, tu dois inverser les 2 lignes je pense.
Code: Tout sélectionner
Disp X
Pause

Tu peux faire juste Pause X

Re: Code plus ou moins

Message non luPosté: 17 Fév 2020, 23:58
de Wistaro
Au passage, tu peux remplacer

If K=0

par

If Not(K

Idem pour S :)