- 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
Code plus ou moins
Voir le premier message non lu • 3 messages
• Page 1 sur 1
Code plus ou moins
-
sangokuhomer
Niveau 10: GR (Guide de Référence)- Messages: 2
- Inscription: 03 Sep 2016, 17:09
- Genre:
- Calculatrice(s):→ MyCalcs profile
Re: Code plus ou moins
É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.
Tu peux faire juste Pause X
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
-
Hamza.SAdmin
Niveau 17: GM (Grand Maître des calculatrices)- Messages: 4464
- Images: 18
- Inscription: 07 Nov 2014, 00:43
- Genre:
- Calculatrice(s):→ MyCalcs profile
Re: Code plus ou moins
Au passage, tu peux remplacer
par
Idem pour S
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:
- Guide: meilleurs programmes & tutoriels - toutes calculatrices
- Guide: programmer en langage C sur TI-83 Premium CE/84+CE
- Groupe Facebook d'entraide autour des études post-bac (prépa, université, IUT...)
Découvre mes programmes et mon site!
-
WistaroSuper Modo
Niveau 15: CC (Chevalier des Calculatrices)- Messages: 3158
- Images: 37
- Inscription: 25 Fév 2013, 16:21
- Localisation: Toulouse
- Genre:
- Calculatrice(s):→ MyCalcs profile
- Classe: Ingénieur en électronique
- YouTube: Wistaro
- Twitter/X: Wistaro
- GitHub: Wistaro
3 messages
• Page 1 sur 1
Qui est en ligne
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 13 invités