π
<-

cycle for

Programmation et implémentation d'algorithmes.

cycle for

Unread postby mark » 20 Jul 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: Select all
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
User avatar
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 9
Joined: 02 Jun 2015, 16:36
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: cycle for

Unread postby critor » 20 Jul 2015, 11:00

Hi!

You could try this output line :
Code: Select all
Pause string(aux1)&"*"&string(aux2)&"="&string(aux1*aux2)
Image
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 53.1%
 
Posts: 42381
Images: 17086
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

Re: cycle for

Unread postby mark » 20 Jul 2015, 11:28

Thanks but I wanted something like this:
3*8=24 --> asd
5*2=10 --> ads
how could I do?
User avatar
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 9
Joined: 02 Jun 2015, 16:36
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: cycle for

Unread postby critor » 20 Jul 2015, 12:24

Then store instead of displaying ?
Code: Select all
string(aux1)&"*"&string(aux2)&"="&string(aux1*aux2)->asd
Image
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 53.1%
 
Posts: 42381
Images: 17086
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

Re: cycle for

Unread postby mark » 20 Jul 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 ...
User avatar
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 9
Joined: 02 Jun 2015, 16:36
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: cycle for

Unread postby Adriweb » 20 Jul 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: Select all
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.

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...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 79.9%
 
Posts: 14836
Images: 1131
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: cycle for

Unread postby mark » 20 Jul 2015, 18:03

OK thank you very much :)
User avatar
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 9
Joined: 02 Jun 2015, 16:36
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: cycle for

Unread postby mark » 25 Jul 2015, 13:53

Code: Select all
()
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
User avatar
mark
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 36%
 
Posts: 9
Joined: 02 Jun 2015, 16:36
Gender: Not specified
Calculator(s):
MyCalcs profile


Return to Programmation

Who is online

Users browsing this forum: ClaudeBot [spider] and 3 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
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.
1906 utilisateurs:
>1876 invités
>23 membres
>7 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)