π
<-
Chat plein-écran
[^]

Code plus ou moins

Code plus ou moins

Unread postby sangokuhomer » 17 Feb 2020, 19:50

Code: Select all
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
User avatar
sangokuhomer
Niveau 10: GR (Guide de Référence)
Niveau 10: GR (Guide de Référence)
Level up: 17.7%
 
Posts: 2
Joined: 03 Sep 2016, 17:09
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Code plus ou moins

Unread postby Hamza.S » 17 Feb 2020, 20:10

É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: Select all
Disp X
Pause

Tu peux faire juste Pause X
Image
User avatar
Hamza.SAdmin
Niveau 17: GM (Grand Maître des calculatrices)
Niveau 17: GM (Grand Maître des calculatrices)
Level up: 28.5%
 
Posts: 4464
Images: 18
Joined: 07 Nov 2014, 00:43
Gender: Male
Calculator(s):
MyCalcs profile

Re: Code plus ou moins

Unread postby Wistaro » 17 Feb 2020, 23:58

Au passage, tu peux remplacer

If K=0

par

If Not(K

Idem pour S :)
Nouveau sur le site, Anonymous ? Avant de poster sur le chat et sur le forum, n'oublie pas de lire les règles. En cas de problème, tu peux m'envoyer un message, je réponds rapidement.

Liens utiles:
Image
Découvre mes programmes et mon site!
User avatar
WistaroSuper Modo
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 88%
 
Posts: 3158
Images: 37
Joined: 25 Feb 2013, 16:21
Location: Toulouse
Gender: Male
Calculator(s):
MyCalcs profile
Class: Ingénieur en électronique
YouTube: Wistaro
Twitter: Wistaro
GitHub: Wistaro


Return to TI-Basic

Who is online

Users browsing this forum: No registered users and 25 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
Phi NumWorks jailbreak
123
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1374 utilisateurs:
>1355 invités
>14 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)