Autorisation : Membre
Nb de messages : 1366
Inscrit le : Ven 25 Mar 2011, 22:58
Posté le : Jeu 04 Aoû 2011, 15:12
Bonjour/bonsoir, je vous présente ici la première version de mon projet pour le zContest 2011.
Voici la présentation française (celle du site du concours)
Citer
Calcul exact par étapes Auteur : sandro Langage / Catégorie : TI-Basic Type : Programme
Compatible : TI 82 STATS, TI 83, TI 83 Plus, TI 84 Plus.
Voci un programme de calcul exact. Il s'effectue par étapes, chacune étant affichée (pratique pour les devoirs
de maths quand le prof demande les étapes intermédiaires).
Pour l'insant, ce programme ne gère que des résultats rationnels.
Les oppérations admises pour l'instant sont : l'addition, la soustraction, la multiplication, la division,
le carré, le cube, et l'inverse. Le programme gère également les parrenthèses et les fractions (sous
la forme {entier relatif:entier positif} ). Les constantes et autres oppérations ne son t pas accèptées pour l'instant.
A la fin, le programme affiche le résultat arrondit.
Pour afficher l'étape suivante, appuyez sur [entrer] ( [enter] ); si rien ne s'affiche de plus, c'est que la TI n'a
pas encore trouvée l'étape suivante.
programmeCALCAUTO (programme à lancer, veille à alterner entre le programme de calcul, et celui de supression de parrenthèses (pour l'instant très court, mais qui ce compliquera quand je rajouterrais les racines).
1 -> A
While A
inString(Str9,"{",A -> A
If A:Then
"("+sub(Str9,A+1,length(Str9)-A -> Str2
If A=/=1
sub(Str9,1,A-1)+Str2 -> Str2
Str2 -> Str9
End
End
1 -> A
While A
inString(Str9,":",A+1 -> A
If A
sub(Str9,1,A-1)+"/"+sub(Str9,A+1,length(Str9)-A -> Str9
End
1 -> A
While A
inString(Str9,"}",A+1 -> A
If A
Then
sub(Str9,1,A-1)+")" -> Str2
If A=/=length(Str9
Str2+sub(Str9,A+1,length(Str9)-A -> Str2
Str2 -> Str9
End
Pause expr(Str9
Code
programme[théta]NIVPAR (trouve quels sont les "niveaux de parrenthèses" (combien siont ouverte à tel endroit)
{0 -> L1
length(Str0 -> L
L -> dim(L1
For(A,1,L
sub(Str0,A,1 -> Str2
If Str2=")
-1 -> L1(A+1
If inString("(sin(cos(tan(sin-1(cos-1(tan-1([e^(][10^(][racine carré)[racine cube]Ýð(",Str2 //les crochets servent juste pour signaler qu'il s'agit d'un seul et même symbol
1 -> L1(A+1
End
cumSum(L1 -> L2[/pre]
[pre]programme[théta]MONONIV (gère les sous-programmes propre à chaque oppération)
3 -> A
While A+3[inférieur ou égal]length(Str0
If Str8=/=Str0
Then
If K
Pause
1 -> K
Disp sub(Str0,3,length(Str0)-4
Str0 -> Str8
End
A -> B
A+1 -> A
A+1 -> C
1 -> [théta]
sub(Str0,A,1 -> Str9
prgm[théta][théta]SIGNE
If Str9="+
prgm[théta][théta]ADD
If Str9="*
prgm[théta][théta]MULT
If Str9="[carré]
DelVar [théta]prgm[théta][théta]CARCU
If Str9="/
prgm[théta][théta]DIV
If Str9="[^-1]
prgm[théta][théta]INV
If Str9="[cube]
prgm[théta][théta]CARCU
End
Code
programme[théta]DELPAR
If inString(Str0,"("
Then
1üB
While B
inString(Str0,"(",B+1 -> B
If B:B -> A
End
A -> B
1 -> C
B+1 -> A
While C
A+1 -> A
sub(Str0,A,1 -> Str2
If Str2=")
C-1 -> C
If inString("(sin(cos(tan(sin-1(cos-1(tan-1([10^(][e^(][racine carré][racine cube]",Str2
C+1 -> C
End
A -> C
sub(Str0,B+1,C-B-1 -> Str4
1 -> D
For(A,1,length(Str4
If not(inString("[moins des relatifs]0.123456789{:}",sub(Str4,A,1
0 -> D
If D
Then
sub(Str0,1,B-1)+Str4+sub(Str0,C+1,length(Str0)-C -> Str0
Return
End
"^/*) -> Str1
"^/*([inverse][carré][cube][pi]e -> Str7
If sub(Str0,A,2)="+{" or "}+"=sub(Str0,B,2
Then
1 -> X
prgm[théta][théta]ADDF
If not(X:Return
Else
prgm[théta][théta]DETBC
If not(X:Return
expr(Str2)^(2+[theta]) -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
expr(Str3)^(2+[theta]) -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
"{"+sub(Str2,4,length(Str2)-3)+":"+sub(Str3,4,length(Str3)-3)+"}" -> Str2
Code
PROGRAMME[théta][théta]DETBC (calcule B et C, respectivement le rand du dernier carractère avant la chaîne exprimée et le premier après)
While Bø1 and inString("[le moins des relatifs]0.123456789à{:}",sub(Str0,B,1
B-1 -> B
End
If inString(Str1,sub(Str0,B,1
DelVar XReturn
If B=1:0 -> B
While Cølength(Str0) and inString("-0.123456789à{:}",sub(Str0,C,1
C+1 -> C
End
If inString(Str7,sub(Str0,C,1
DelVar XReturn
If C=length(Str0:C+1 -> C
sub(Str0,B+1,C-B-1 -> Str2
Code
[théta][théta]DIV (division d'un nombre décimal par un autre
"/^) -> Str1
"^([inverse][carré][cube][pi]e -> Str7 //les crochets servent uniquement a marquer les carracteres speciaux
1 -> X
If "}"=sub(Str0,A-1,1) and inString("0.-123456789",sub(Str0,A+1,1
Then
prgm[theta][theta]DIVFPN
If not(X:Return
Else
If "/{"=sub(Str0,A,2
Then
prgm[thete][theta]DIVPF
If not(X:Return
Else
prgm[theta][theta]DETBC
If not(X:Return
expr(Str2 -> E
If not(fPart(E[E des puissances de 10]5
Then
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
Goto Q
End
expr(Str2 -> U
expr(Str3 -> V
While fPart(U) or fPart(V
10U -> U
10V -> V
End
(-2(V<0)+1)gcd(abs(U),abs(V))^-1 -> N
UN -> U
VN -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
(-2(V<0)+1)gcd(abs(U),abs(V))^-1 -> N
UN -> U
VN -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
V -> E
LinReg(ax+b)L5,L6,Y9
EquåString(Y9,Str3
sub(Str3,4,length(Str3)-3 -> Str3
If V=/=0
"{"+Str2+":"+Str3+"}" -> Str2
Code
programme[théta][théta]DIVPF (division par une fraction)
inString(Str0,":",A+2 -> H
inString(Str0,"}",H+2 -> I
sub(Str0,A+2,H-A-2 -> Str2
sub(Str0,H+1,I-H-1 -> Str3
"*{"+Str3+":"+Str2+"}" -> Str2
I+1 -> C
If inString("^[^-1][^2][^3][pi](e",sub(Str0,C,1
DelVar X
Code
programme[théta][théta]INV (inverse d'un nombre)
While inString("[moins des relatifs]0.123456789{:}",sub(Str0,B,1
B-1 -> B
End
sub(Str0,B+1,A-B-1 -> Str4
inString(Str4,":" -> H
If H
Then
sub(Str4,2,H-2 -> Str2
sub(Str4,H+1,length(Str4)-H-1 -> Str3
expr(Str2 -> V
expr(Str3 -> U
Else
expr(Str4) -> V
1 -> U
End
While fPart(U) or fPart(V
10U -> U
10V -> V
End
(-2(U<0)+1)gcd(abs(U),abs(V))^-1 -> H
UH -> U
VH -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
If U=0
Then
"0 -> Str2
Else
sub(Str2,4,length(Str2)-3 -> Str2
If V=/=1
"{"+Str2+":"+sub(Str3,4,length(Str3)-3)+"}" -> Str2
sub(Str0,1,B)+Str2+sub(Str0,A+1,length(Str0)-A -> Str0
Code
programme[théta][théta]MULT (multiplication)
"^)/ -> Str1
"^([^-1][^2][^3][pi]e -> Str7
1 -> X
If "}"=sub(Str0,A-1,1) or "{"=sub(Str0,A+1,1
Then
prgm[theta][theta]MULTF
If not(X:Return
Else
prgm[theta][theta]DETBC
If not(X:Return
expr(Str2 -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
End
sub(Str0,1,B)+Str2+sub(Str0,C,length(Str0)-C+1 -> Str0
1 -> A
Code
programme[théta][théta]MULTF (multiplication avec fraction(s) )
While B=/=1 and inString(":{}-0.123456789",sub(Str0,B,1
B-1 -> B
End
NP -> U
OQ -> V
(-2(V<0)+1)gcd(abs(U),abs(V))^-1üG
UG -> U
VG -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
sub(Str3,4,length(Str3)-3 -> Str3
If U=0
Then
"0 -> Str2
Else
If V=/=1
"{"+Str2+":"+Str3+"}" -> Str2
Code
programme[théta][théta]SIGNE (transforme la soustraction en addition)
1 -> Y
While Y
inString(Str0,"[moins des soustractions]",Y -> Y
If Y
Then
If "{"=sub(Str0,Y+1,1
Then
sub(Str0,1,Y-1)+"+{[moins des relatifs]"+sub(Str0,Y+2,length(Str0)-Y-1 -> Str0
Else
sub(Str0,1,Y-1)+"+[moins des relatifs]"+sub(Str0,Y+1,length(Str0)-Y -> Str0
End
End
End
Sandro
---------------------- mort à l'inutile, place à la mémoire libre et aux programmes
Autorisation : Membre
Nb de messages : 3738
Inscrit le : Lun 19 Oct 2009, 21:25
Posté le : Jeu 04 Aoû 2011, 17:06
CALCAUTO/AUTOCALC : la référence n'est pas compliquée.
Bonne chance pour la fin !
Je t'autorise à t'inspirer de mes codes pour les simplifications des racines.
Mais fais mieux encore si tu peux.
Je n'ai pas le courage de l'étudier en détails comme je fais souvent. Un jour peut-être...
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 1366
Inscrit le : Ven 25 Mar 2011, 22:58
Posté le : Ven 05 Aoû 2011, 9:26
Merci beaucoup, mais sauf peut-être le racine(X)=A*racine(B), je ne pense pas que ça va me servir vue que je n'ai pas l'intention de laissair la TI calculer le résultat décimal (sinon, je serai dans la M**** si j'ai un truc du genre rac(5)*rac(7)*pi*e*rac(e).
Sandro
PS : pour le nom, si tu trouve mieux, n'hésite pas, mais je n'ai pas trouvé mieu pour l'instant en 8 carractères.
---------------------- mort à l'inutile, place à la mémoire libre et aux programmes
Autorisation : Membre
Nb de messages : 1366
Inscrit le : Ven 25 Mar 2011, 22:58
Posté le : Sam 06 Aoû 2011, 12:18
Merci beaucoup pour les propositions de noms, sinon, tu m'étonne, tu n'a pas de cable, j'ai mis tous les liens de téléchargement exprès.
Sinon, si tu veut teste sans recopier, tu peut toujours essayer sur émulateur.
Le zContest2001 est un concours de programmation sur z80 en 3 catégories (basic pur, basic étendu(avec codes héxa,avec bibliothèques, axe parser,...), et assembleur pur). Il faut rendre le programme jusqu'au 1er decembre.
[url=formum de mise en place]http://www.yaronet.com/posts.php?sl=&s=138721&p=1[/url]
[url=site du concours]http://tiforge.info/zcontest3/[/url]
Sandro
Sandro
---------------------- mort à l'inutile, place à la mémoire libre et aux programmes