π
<-
Chat plein-écran
[^]

cycle for

Programmation et implémentation d'algorithmes.

cycle for

Message non lude mark » 20 Juil 2015, 10:53

Hello to all guys .. I ask my help in solving this problem. I write the code and then requests that I would get
Code: Tout sélectionner
Prgm
Dialog
Request "N.corpi",aux
EndDlog
expr(aux)->aux
For i,1,aux,1
............................??????
Dialog
Request "M",aux1
Request "V",aux2
EndDlog
expr(aux1)->aux1
expr(aux2)->aux2
Pause aux1*aux2
EndFor
EndPrgm


The calculator asks me how many are the bodies and according to the number of bodies, the calculator executes the loop. Suppose that the bodies are 2, then the cycle will be repeated for 2 times.
It will be like this:


N. Corpi 2

M= 3
V= 8

I want to see screen 3 * 8 = 24


M= 5
V= 2


I want to see screen 5 * 2 = 10

I can not save in a variable 3 * 8 = 24 and 5 * 2 = 10

Can anyone help me?
thanks a lot
mark
Avatar de l’utilisateur
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 9
Inscription: 02 Juin 2015, 16:36
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: cycle for

Message non lude critor » 20 Juil 2015, 11:00

Hi!

You could try this output line :
Code: Tout sélectionner
Pause string(aux1)&"*"&string(aux2)&"="&string(aux1*aux2)
Image
Avatar de l’utilisateur
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Prochain niv.: 42.3%
 
Messages: 41496
Images: 14632
Inscription: 25 Oct 2008, 00:00
Localisation: Montpellier
Genre: Homme
Calculatrice(s):
MyCalcs profile
YouTube: critor3000
Twitter/X: critor2000
GitHub: critor

Re: cycle for

Message non lude mark » 20 Juil 2015, 11:28

Thanks but I wanted something like this:
3*8=24 --> asd
5*2=10 --> ads
how could I do?
Avatar de l’utilisateur
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 9
Inscription: 02 Juin 2015, 16:36
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: cycle for

Message non lude critor » 20 Juil 2015, 12:24

Then store instead of displaying ?
Code: Tout sélectionner
string(aux1)&"*"&string(aux2)&"="&string(aux1*aux2)->asd
Image
Avatar de l’utilisateur
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Prochain niv.: 42.3%
 
Messages: 41496
Images: 14632
Inscription: 25 Oct 2008, 00:00
Localisation: Montpellier
Genre: Homme
Calculatrice(s):
MyCalcs profile
YouTube: critor3000
Twitter/X: critor2000
GitHub: critor

Re: cycle for

Message non lude mark » 20 Juil 2015, 12:44

If the bodies were 3 and 2 what you have written is not good.I do not know in advance whether the bodies that I have to enter are 2, 3, 4 or 5 etc ...
Avatar de l’utilisateur
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 9
Inscription: 02 Juin 2015, 16:36
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: cycle for

Message non lude Adriweb » 20 Juil 2015, 17:47

I suppose you could store the results in a list (called tmp, in the example), and do something like this, inside of a loop at the end of your program:
Code: Tout sélectionner
string(tmp[idx1])&"*"&string(tmp[idx2])&"="&string(tmp[idx1]*tmp[idx2])->asd

That also assume you know the indices for each (idx1 and idx2) - which is something you should know.

But it's less easy than printing things within the loop like Critor proposed first - you'd just have not to print anything else in between.
Image

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14615
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: cycle for

Message non lude mark » 20 Juil 2015, 18:03

OK thank you very much :)
Avatar de l’utilisateur
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 9
Inscription: 02 Juin 2015, 16:36
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: cycle for

Message non lude mark » 25 Juil 2015, 13:53

Code: Tout sélectionner
()
Prgm

Lbl top
ClrIO
Dialog
Title "Corpi"
Text "# Corpi?"
Request "N=",nv,0
Text "Ex: N=3"
EndDlog
If ok=0:Goto quit

Disp "#Corps="&nv

expr(nv)n
newList(n)ls
newList(n)ls2

For i,1,n
Input "M"&string(i)&"=",tmp
tmpls[i]
Input "V"&string(i)&"=",tmp
tmpls2[i]
EndFor

Pause "M="&string(ls)
Pause "V="&string(ls2)
Pause "M*V="&string(ls*ls2)

For i,1,n
Pause "M"&string(i)&"*V"&string(i)&"="&string(ls[i])&"*"&string(ls2[i])&"="&string(ls[i]*ls2[i])
EndFor


EndPrgm



I took your advice, but now I do not know how to store it in a variable that I see on the screen .... That is, if

N.Corpi = 3

How to save it in the variable asd?

M1*V1+M2*V2+M3*V3 --> asd and save it in the variable asd
Avatar de l’utilisateur
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 9
Inscription: 02 Juin 2015, 16:36
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile


Retourner vers Programmation

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 25 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.
1568 utilisateurs:
>1554 invités
>9 membres
>5 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)