π
<-
Chat plein-écran
[^]

Code plus ou moins

Code plus ou moins

Message non lude sangokuhomer » 17 Fév 2020, 19:50

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
Avatar de l’utilisateur
sangokuhomer
Niveau 10: GR (Guide de Référence)
Niveau 10: GR (Guide de Référence)
Prochain niv.: 17.7%
 
Messages: 2
Inscription: 03 Sep 2016, 17:09
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: Code plus ou moins

Message non lude Hamza.S » 17 Fév 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: Tout sélectionner
Disp X
Pause

Tu peux faire juste Pause X
Image
Avatar de l’utilisateur
Hamza.SAdmin
Niveau 17: GM (Grand Maître des calculatrices)
Niveau 17: GM (Grand Maître des calculatrices)
Prochain niv.: 28.5%
 
Messages: 4463
Images: 18
Inscription: 07 Nov 2014, 00:43
Genre: Homme
Calculatrice(s):
MyCalcs profile

Re: Code plus ou moins

Message non lude Wistaro » 17 Fév 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!
Avatar de l’utilisateur
WistaroSuper Modo
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Prochain niv.: 88%
 
Messages: 3158
Images: 37
Inscription: 25 Fév 2013, 16:21
Localisation: Toulouse
Genre: Homme
Calculatrice(s):
MyCalcs profile
Classe: Ingénieur en électronique
YouTube: Wistaro
Twitter/X: Wistaro
GitHub: Wistaro


Retourner vers TI-Basic

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 6 invités

-
Rechercher
-
Social TI-Planet
-
Sujets à la une
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
-
Faire un don / Premium
Pour plus de concours, de lots, de tests, nous aider à payer le serveur et les domaines...
Faire un don
Découvrez les avantages d'un compte donateur !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partenaires et pub
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1536 utilisateurs:
>1511 invités
>21 membres
>4 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Autres sites intéressants
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)