Précédente Accueil Remonter Suivante

MATH 2

Visual Basic for MS-DOS

 

Module 1

Module 2

Module 3

Module 4

Module 5

Module 6

Module 7

Module 8

 

DECLARE SUB getinvimouse (rr%)
DECLARE SUB fleches (v%, h%, w$(), np%, r%, coul%, drap%, v2%, h3%)
DECLARE SUB ouinon (r$)
DECLARE SUB tableauexo (p$())
DECLARE SUB lettre (re%, ni%, un2$(), di2$(), ex2$(), ch$(), mot$(), rt$, gg$, nom$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB attendre (tx!)
DECLARE SUB bilan (ma$(), niveaux%(), eleve%, VarEnreg AS ANY, rt$, noir%, bleu%, rouge%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB cadre1 (v%, h%, l%, nli%, c%, c2%, c3%)
DECLARE SUB cadrenb (v%, h%, l%, nli%, c%, c2%, c3%)
DECLARE SUB calmoy (t$(), moy$(), niveaux%())
DECLARE SUB centre (v%, coul%, ph$)
DECLARE SUB chiffreslettres (x%, y%, t%)
DECLARE SUB convertir (z$)
DECLARE SUB entree (y%, z%)
DECLARE SUB flechesmenu (w$(), r%, coul%)
DECLARE SUB getinvi (rr%)
DECLARE SUB quitter (x%, y%)
DECLARE SUB titre ()
DECLARE SUB additions (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB cmental (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB divisions (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB encadre (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB fractions (re%, ni%, rt$, gg$, pre$, titr$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)
DECLARE SUB memoire (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB multiples (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB orth (re%, ni%, mo$(), mo2$(), mo3$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB romains (re%, ni%, UR$(), DR$(), CR$(), MR$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB soustractions (re%, ni%, flagscreen%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB moitie (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB nombrechiffre (re%, ni%, un$(), di$(), ex$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)
DECLARE SUB regle (re%, ni%, flagscreen%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB tables1 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB tables2 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB trouve (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB valeurchiffres (re%, ni%, ta1$(), ta$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB choixfois (re%, ni%, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB choixmulti (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB classement (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB choixprobleme (re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)
'Biblio AAS MATH II
'Daniel Clerc 6/2/97
'version 1.1

'revoir orth analyse ===

DEFINT A-Z
'procédures

'variables globales
COMMON SHARED pre$, rt$, gg$, gg2$, titr$, prog, ni, eleve, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur

' Inclut les fichiers contenant les déclarations relatives aux procédures appelées.
'$INCLUDE: 'MOUSE.BI'
'$INCLUDE: 'VBDOS.BI'

CONST FALSE = 0
CONST TRUE = NOT FALSE

rt$ = CHR$(17) + CHR$(196) + CHR$(217)
gg$ = CHR$(24) + " " + CHR$(25) + " puis " + rt$

programme2$ = "menuexo" '===
ON ERROR GOTO erreur '===

TYPE TypeEnreg
nom AS STRING * 20
prenom AS STRING * 20
nbexo AS STRING * 21
Divers AS STRING * 50
notes AS STRING * 3000
END TYPE
DIM VarEnreg AS TypeEnreg

ma = 21
DIM t$(100), p$(ma), un$(9), di$(9), ex$(9), ta1$(9), ta$(8), moy$(39), niveaux(ma)
DIM UR$(9), DR$(9), CR$(9), MR$(3)
DIM un2$(10), di2$(10), ex2$(10), ch$(36), mot$(45)
DIM mo$(20), mo2$(20), mo3$(20)'pour orth
DIM fois1$(4), fois2$(3) 'pour fois

RANDOMIZE TIMER
OPEN "pointeur.dat" FOR INPUT AS #1
INPUT #1, eleve, sens, couleur, texte, lecture$
CLOSE
OPEN "pointeur.dat" FOR OUTPUT AS #1
WRITE #1, eleve, 2, 1, texte, lecture$
CLOSE

IF couleur = 1 THEN
noir = 0: bleu = 1: vert = 2: rouge = 4: marron = 6: blanc = 7: vertclair = 10: cyanclair = 11: rougeclair = 12: jaune = 14: blancbrill = 15
ELSE
noir = 0: bleu = 0: vert = 15: rouge = 7: marron = 7: blanc = 7: vertclair = 15: cyanclair = 15: rougeclair = 15: jaune = 15: blancbrill = 15
END IF

flagscreen = 0
SCREEN 9
SCREEN 0

COLOR , noir, noir: CLS : KEY OFF: LOCATE , , 0
GOSUB init

IF sens = 1 AND eleve > 0 THEN
CALL bilan(p$(), niveaux(), eleve, VarEnreg, rt$, noir, bleu, rouge, vertclair, cyanclair, rougeclair, jaune, blancbrill)
END IF

menuprincipal:
' Vérifie que le gestionnaire de souris est installé.
MouseInit
MouseShow

'DEF SEG = 0
'POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
'POKE &H417, (PEEK(&H417) AND &HBF) 'minus
'DEF SEG
COLOR , bleu, noir: CLS
CALL cadre(2, 20, 40, 2, vert)
COLOR , vert
CALL centre(3, blancbrill, "ACTIVITES de MATHEMATIQUES - niveau II")
COLOR , bleu

IF eleve <> 0 THEN
'lecture des notes
OPEN "fichier.dat" FOR RANDOM AS #1 LEN = LEN(VarEnreg)
GET #1, eleve, VarEnreg
nom$ = RTRIM$(VarEnreg.nom)
pre$ = RTRIM$(VarEnreg.prenom)
'math niv 2 en 4°
nbexo$ = LTRIM$(STR$(VAL(MID$(VarEnreg.nbexo, 10, 3))))
resultat$ = MID$(VarEnreg.notes, 1201, 400)
j = 1
FOR i = 1 TO 200 STEP 2 '===
t$(j) = MID$(resultat$, i, 2)
j = j + 1
NEXT
CLOSE
CALL calmoy(t$(), moy$(), niveaux())
END IF

IF VAL(nbexo$) > 1 THEN
COLOR jaune
z$ = RTRIM$(nbexo$) + " exercices"
LOCATE 4, 79 - LEN(z$): PRINT z$
END IF
LOCATE 4, 2
COLOR jaune
IF eleve <> 0 THEN
w$ = pre$ + " " + nom$
IF LEN(w$) > 17 THEN
PRINT nom$
ELSE
PRINT w$
END IF
END IF

CALL tableauexo(p$())

'affiche liste exo
h1 = 6: h3 = 32: h3 = 58
COLOR blancbrill
LOCATE 7
FOR i = 1 TO 7
LOCATE , h1: PRINT p$(i): PRINT
NEXT
LOCATE 7
FOR i = 8 TO 14
LOCATE , h3: PRINT p$(i): PRINT
NEXT
LOCATE 7
FOR i = 15 TO 21
LOCATE , h3: PRINT p$(i): PRINT
NEXT

IF eleve <> 0 THEN
'affiche éval sur trois colonnes
COLOR , noir
debut = 1: fin = 7: h = 4
FOR boucle = 1 TO 3
LOCATE 7
FOR i = debut TO fin
LOCATE , h
IF moy$(i) = "" THEN
PRINT " ": PRINT
ELSEIF (VAL(moy$(i)) = 9 OR VAL(moy$(i)) = 10) THEN
COLOR vertclair: PRINT "A": PRINT
ELSEIF (VAL(moy$(i)) = 7 OR VAL(moy$(i)) = 8) THEN
COLOR vert: PRINT "B": PRINT
ELSEIF (VAL(moy$(i)) = 6 OR VAL(moy$(i)) = 5) THEN
COLOR jaune: PRINT "C": PRINT
ELSE
COLOR rougeclair: PRINT "D": PRINT
END IF
COLOR blancbrill
NEXT
debut = fin + 1: fin = fin + 7: IF fin > ma THEN fin = ma
h = h + 26
NEXT boucle
END IF

CALL flechesmenu(p$(), prog, rouge)
COLOR , noir

IF prog = 0 THEN
COLOR , bleu
LOCATE 22, 1: PRINT SPACE$(80)
LOCATE 22, 28
COLOR blanc: BEEP: PRINT "Quitter ";
CALL ouinon(r$)
IF r$ = "O" THEN GOTO fin
GOTO menuprincipal
END IF

IF prog = 42 THEN
CALL bilan(p$(), niveaux(), eleve, VarEnreg, rt$, noir, bleu, rouge, vertclair, cyanclair, rougeclair, jaune, blancbrill)
GOTO menuprincipal
END IF

COLOR , noir: CLS
titr$ = p$(prog): ni = 1

COLOR , noir

'valeur de la matière
mat = 0
FOR i = 1 TO prog - 1
mat = mat + niveaux(i)
NEXT

SELECT CASE prog

CASE 1
CALL valeurchiffres(re%, ni%, ta1$(), ta$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 2
CALL classement(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 3
CALL orth(re, ni, mo$(), mo2$(), mo3$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 4
CALL lettre(re%, ni%, un2$(), di2$(), ex2$(), ch$(), mot$(), rt$, gg$, nom$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 5
CALL nombrechiffre(re%, ni%, un$(), di$(), ex$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)

CASE 6
CALL regle(re%, ni%, flagscreen%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 7
CALL encadre(re, ni, rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 8
CALL romains(re, ni, UR$(), DR$(), CR$(), MR$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 9
CALL additions(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 10
CALL soustractions(re%, ni%, flagscreen, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 11
CALL tables1(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 12
CALL tables2(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 13
CALL choixmulti(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 14
CALL divisions(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 15
CALL cmental(re, ni, rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 16
CALL choixfois(re, ni, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 17
CALL moitie(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 18
CALL trouve(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 19
IF flagscreen = 1 THEN
CALL multiples(re, ni, rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
ELSE
CALL fractions(re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur)
END IF
CASE 20
CALL memoire(re, ni, rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)

CASE 21
CALL choixprobleme(re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)

END SELECT

GOSUB enregistre
CALL entree(noir, noir)
GOTO menuprincipal
END

fin:
COLOR , noir
IF eleve <> 0 THEN
CALL bilan(p$(), niveaux(), eleve, VarEnreg, rt$, noir, bleu, rouge, vertclair, cyanclair, rougeclair, jaune, blancbrill)
END IF
CLS
RUN programme2$
END

init:
'connaissance des nombres
DATA Valeur des chiffres,2
DATA Tri des nombres,3
DATA Orthographe,2
DATA Nombres en lettres,3
DATA Nombres en chiffres,3
DATA Règle graduée,2
DATA Encadrement,2
DATA Chiffres romains,3
'calcul
DATA Additions,3
DATA Soustractions,3
DATA Tables de multi.,4
DATA Tableau de multi.,2
DATA Multiplications,4
DATA Divisions,4
DATA Calcul mental,3
DATA "Dix-cent-mille",4
DATA Moitié d'un nombre,3
DATA Nombre à trouver,4

DATA Multiples,2
DATA Mémorisation,2
'problèmes
DATA Problèmes,3

FOR i = 1 TO ma: READ p$(i), niveaux(i): NEXT
IF flagscreen = 0 THEN
p$(19) = "Fractions"
END IF

'nombrechiffres
DATA "un ","deux ","trois ","quatre ","cinq ","six ","sept ","huit ","neuf "
DATA "dix ","vingt ","trente ","quarante ","cinquante ","soixante ","soixante dix ","quatre vingt ","quatre vingt dix "
DATA "onze ","douze ","treize ","quatorze ","quinze ","seize "
FOR i = 1 TO 9: READ un$(i): NEXT
FOR i = 1 TO 9: READ di$(i): NEXT
FOR i = 1 TO 6: READ ex$(i): NEXT

'valeurchiffres
'niveau 1
DATA centaines de millions,dizaines de millions,unités de millions
DATA centaines de mille,dizaines de mille,unités de mille
DATA centaines,dizaines,unités
FOR i = 1 TO 9: READ ta1$(i): NEXT

'niveau 2
DATA dizaines de mille,unités de mille,centaines,dizaines,unités,dixièmes,centièmes,millièmes
FOR i = 1 TO 8: READ ta$(i): NEXT

'romains
DATA I,II,III,IV,V,VI,VII,VIII,IX
DATA X,XX,XXX,XL,L,LX,LXX,LXXX,XC
DATA C,CC,CCC,CD,D,DC,DCC,DCCC,CM
DATA M,MM,MMM
FOR i = 1 TO 9: READ UR$(i): NEXT
FOR i = 1 TO 9: READ DR$(i): NEXT
FOR i = 1 TO 9: READ CR$(i): NEXT
FOR i = 1 TO 3: READ MR$(i): NEXT

'lettre
DATA "un ","deux ","trois ","quatre ","cinq ","six ","sept ","huit ","neuf "
DATA "dix ","vingt ","trente ","quarante ","cinquante ","soixante ","soixante dix ","quatre vingt ","quatre vingt dix "
DATA "onze ","douze ","treize ","quatorze ","quinze ","seize "
FOR i = 1 TO 9: READ un2$(i): NEXT
FOR i = 1 TO 9: READ di2$(i): NEXT
FOR i = 1 TO 6: READ ex2$(i): NEXT
'idem
DATA 3 472,551,7 288,893,7 115,8 214,326,5 570,432,1 745,2 850,8 963,2 612
DATA 5 120,2 540,3 910,4 360,5 245

DATA 76 080,29 001,61 015,23 020,84 050,39 100
DATA 12 005,30 082,140 000,30 070,103 020,320 100,400 500
DATA 207 000,27 608 005,2 800 030,6 500 009,4 000 800
FOR i = 1 TO 36: READ ch$(i): NEXT
'idem
FOR i = 1 TO 9
mot$(i) = RTRIM$(un2$(i))
NEXT
FOR j = 1 TO 9
mot$(i) = RTRIM$(di2$(j))
i = i + 1
NEXT
FOR j = 1 TO 6
mot$(i) = RTRIM$(ex2$(j))
i = i + 1
NEXT
mot$(25) = "cent"
mot$(26) = "mille"
mot$(27) = "million"
mot$(28) = "et"
mot$(29) = "millions"
mot$(30) = "cents"
mot$(31) = "zéro"
mot$(32) = "zero"
'+ pour chiflet
mot$(33) = "dixième"
mot$(34) = "dixieme"
mot$(35) = "centième"
mot$(36) = "centieme"
mot$(37) = "millième"
mot$(38) = "millieme"
mot$(39) = "dixièmes"
mot$(40) = "dixiemes"
mot$(41) = "centièmes"
mot$(42) = "centiemes"
mot$(43) = "millièmes"
mot$(44) = "milliemes"
mot$(45) = "virgule"

'orthomath
DATA zéro,trois,quatre,six,sept,huit,dix,onze,douze,treize
DATA quatorze,quinze,seize,vingt,trente,quarante,cinquante
DATA soixante,cent,mille
FOR i = 1 TO 20: READ mo$(i): NEXT
'idem
DATA calcul,soustraction,multiplication,somme,reste,mathématiques,solution
DATA fraction,unité,dizaine,centaine
DATA addition,problème,retenue,résultat,chiffre,total,décimal,division,quotient
FOR i = 1 TO 20: READ mo2$(i): NEXT
'idem
DATA "0","3","4","6","7","8","10","11","12","13","14","15","16","20","30","40"
DATA "50", "60", "100", "1000"
FOR i = 1 TO 20: READ mo3$(i): NEXT

'fois 21/12/94
DATA dizaines,centaines,unités de mille,dizaines de mille
DATA dixièmes,centièmes,millièmes

FOR i = 1 TO 4
READ fois1$(i)
NEXT
FOR i = 1 TO 3
READ fois2$(i)
NEXT

gg2$ = CHR$(24) + " " + CHR$(25) + " " + CHR$(27) + " " + CHR$(26) + " puis " + rt$
RETURN

enregistre:
COLOR , noir
IF eleve = 0 THEN RETURN
CALL centre(23, blanc, "Enregistrement de la note")
re$ = LTRIM$(STR$(re)): IF LEN(re$) = 1 THEN re$ = " " + re$
pointeur = ni + mat
OPEN "fichier.dat" FOR RANDOM AS #1 LEN = LEN(VarEnreg)
GET #1, eleve, VarEnreg
nbexo$ = VarEnreg.nbexo

nombre$ = LTRIM$(STR$(VAL(MID$(nbexo$, 10, 3)) + 1))
IF LEN(nombre$) = 1 THEN
nombre$ = "00" + nombre$
ELSEIF LEN(nombre$) = 2 THEN
nombre$ = "0" + nombre$
END IF
'=== math est en 4° -> 9
IF VAL(nombre$) < 1000 THEN
VarEnreg.nbexo = MID$(nbexo$, 1, 9) + nombre$ + MID$(nbexo$, 13)
END IF

notes$ = MID$(VarEnreg.notes, 1201, 400)
IF pointeur = 1 THEN
notes$ = re$ + MID$(notes$, 2 * pointeur + 1)
ELSE
notes$ = MID$(notes$, 1, (pointeur - 1) * 2) + re$ + MID$(notes$, 2 * pointeur + 1)
END IF

VarEnreg.notes = MID$(VarEnreg.notes, 1, 1200) + notes$ + MID$(VarEnreg.notes, 1601)
PUT #1, eleve, VarEnreg
CLOSE #1
CALL attendre(.5)
LOCATE 23: PRINT SPACE$(80)
RETURN

erreur:
programme$ = "exo_ma2"

IF ERR = 5 THEN
flagscreen = 1
RESUME NEXT
END IF

SCREEN 0
COLOR , bleu: CLS
BEEP
CALL cadre(8, 5, 70, 9, rouge)
COLOR , rouge
CALL centre(10, blanc, "ATTENTION")


SELECT CASE ERR
CASE 71
CALL centre(12, blancbrill, "Disque non prêt")

CASE 70
CALL centre(12, blancbrill, "Disquette protégée")

CASE 53, 57, 72
CALL centre(12, blancbrill, "Problème sur le disque")

CASE 61
CALL centre(12, blancbrill, "Disque plein")

CASE 25, 26, 68
CALL centre(12, blancbrill, "Imprimante non prête")

CASE 27
CALL centre(12, blancbrill, "Imprimante sans papier")

CASE ELSE
CALL centre(12, blancbrill, "Erreur système n°" + LTRIM$(STR$(ERR)))
CALL centre(14, blancbrill, "Essayez de relancez le programme.")
CLOSE
w$ = INPUT$(1)
COLOR , noir: CLS
END

END SELECT

CALL centre(14, blancbrill, "Corrigez puis tapez " + rt$ + " [Echap] = Fin")
CALL getinvimouse(r)
IF r = 27 THEN COLOR , noir: CLS : END
COLOR , bleu: CLS : RUN programme$
RESUME


DEFINT A-Z
SUB attendre (tx!)
t! = tx! * 2
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
debut! = TIMER
DO
fin! = TIMER
IF INKEY$ <> "" THEN EXIT DO
LOOP WHILE fin! - debut! < t!
END SUB

DEFINT A-Z
SUB bilan (ma$(), niveaux(), eleve, VarEnreg AS TypeEnreg, rt$, noir, bleu, rouge, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'6/4/95
ma = 21
DIM t$(100), moy$(ma), bi$(21)
FOR i = 1 TO 21: bi$(i) = ma$(i): NEXT

ll$ = STRING$(30, ".")
pt$ = MID$(ll$, 1, 15)
ni$ = "Niveau " + CHR$(26) + " 1 2 3 4"

COLOR , noir: CLS

'lecture des notes
OPEN "fichier.dat" FOR RANDOM AS #1 LEN = LEN(VarEnreg)
GET #1, eleve, VarEnreg
nom$ = RTRIM$(VarEnreg.nom)
pre$ = RTRIM$(VarEnreg.prenom)
'math niv 2 en 4°
nbexo$ = LTRIM$(MID$(VarEnreg.nbexo, 10, 3))
IF VAL(nbexo$) = 0 THEN CLOSE : EXIT SUB
resultat$ = MID$(VarEnreg.notes, 1201, 400)
CLOSE

titr$ = "bilan"
CALL titre

j = 1
FOR i = 1 TO 200 STEP 2 '===
t$(j) = MID$(resultat$, i, 2)
j = j + 1
NEXT
CALL calmoy(t$(), moy$(), niveaux())

'moy générale
tt = 0: nt = 0
FOR j = 1 TO ma
IF moy$(j) <> "" THEN tt = tt + VAL(moy$(j)): nt = nt + 1
NEXT j
IF nt = 0 THEN moygen$ = " " ELSE moygen$ = LTRIM$(STR$(INT((tt / nt) * 10) / 10))

IF LEN(pre$ + nom$) > 25 THEN pre$ = ""
z$ = pre$ + " " + nom$ + " a fait" + STR$(VAL(nbexo$)) + " exercice"
IF VAL(nbexo$) > 1 THEN z$ = z$ + "s"
z$ = z$ + " de mathématiques (niveau II)"
COLOR , marron
CALL centre(4, blancbrill, " " + z$ + " ")
COLOR , bleu

LOCATE 6, 16: COLOR vertclair: PRINT ni$: COLOR jaune: LOCATE 6, 36: PRINT "Moy"
COLOR vertclair: LOCATE 6, 57: PRINT ni$: COLOR jaune: LOCATE 6, 77: PRINT "Moy"

COLOR , rouge
v = 7: h = 1: debut = 8: fin = 18: GOSUB cadre
v = 7: h = 42: debut = 8: fin = 17: GOSUB cadre
LOCATE 8
FOR i = 1 TO 11
LOCATE , 2: PRINT bi$(i); " "; LEFT$(ll$, 20 - LEN(bi$(i)))
NEXT
LOCATE 8
FOR i = 12 TO ma
LOCATE , 43: PRINT bi$(i); " "; LEFT$(ll$, 20 - LEN(bi$(i)))
NEXT

'affichage des moyennes
LOCATE 8
FOR i = 1 TO 11
LOCATE , 36
IF moy$(i) = "" THEN
PRINT
ELSEIF VAL(moy$(i)) = 9 OR VAL(moy$(i)) = 10 THEN
COLOR blancbrill
PRINT moy$(i);
COLOR vertclair
LOCATE , 38
PRINT "A"
ELSEIF VAL(moy$(i)) = 7 OR VAL(moy$(i)) = 8 THEN
COLOR blancbrill
PRINT moy$(i);
COLOR vert
LOCATE , 38
PRINT "B"
ELSEIF VAL(moy$(i)) = 6 OR VAL(moy$(i)) = 5 THEN
COLOR blancbrill
PRINT moy$(i);
LOCATE , 38
COLOR jaune
PRINT "C"
ELSE
COLOR blancbrill
PRINT moy$(i);
COLOR rougeclair
LOCATE , 38
PRINT "D"
END IF
NEXT
LOCATE 8
FOR i = 12 TO ma
LOCATE , 77
IF moy$(i) = "" THEN
PRINT
ELSEIF VAL(moy$(i)) = 9 OR VAL(moy$(i)) = 10 THEN
COLOR blancbrill
PRINT moy$(i);
COLOR vertclair
LOCATE , 79
PRINT "A"
ELSEIF VAL(moy$(i)) = 7 OR VAL(moy$(i)) = 8 THEN
COLOR blancbrill
PRINT moy$(i);
COLOR vert
LOCATE , 79
PRINT "B"
ELSEIF VAL(moy$(i)) = 5 OR VAL(moy$(i)) = 6 THEN
COLOR blancbrill
PRINT moy$(i);
LOCATE , 79
COLOR jaune
PRINT "C"
ELSE
COLOR blancbrill
PRINT moy$(i);
COLOR rougeclair
LOCATE , 79
PRINT "D"
END IF
NEXT
COLOR blanc


'++++++++++++++
v = 8
debut = 1
FOR Valeur = 1 TO 11
fin = debut + (niveaux(Valeur) - 1)
h = 24: GOSUB place
debut = fin + 1: v = v + 1
NEXT

v = 8
FOR Valeur = 12 TO ma
fin = debut + (niveaux(Valeur) - 1)
h = 65: GOSUB place
debut = fin + 1: v = v + 1
NEXT
'++++++++++
COLOR , bleu
IF VAL(moygen$) <> 0 THEN
COLOR cyanclair: LOCATE 19, 43
CALL convertir(moygen$)
PRINT "Moyenne générale : "; moygen$; " sur 10"
END IF
CALL entree(noir, noir)

EXIT SUB

place:
LOCATE v
FOR i = debut TO fin
LOCATE , h
IF VAL(t$(i)) < 10 THEN PRINT " ";
IF t$(i) <> " " THEN PRINT LTRIM$(t$(i)); ELSE PRINT "-";
h = h + 3
NEXT
RETURN

cadre:
COLOR blancbrill
LOCATE v, h: PRINT "┌─────────────────────┬──┬──┬──┬──┬───┐"
FOR i = debut TO fin
LOCATE , h: PRINT "│ │ │ │ │ │ │"
NEXT i
LOCATE , h: PRINT "└─────────────────────┴──┴──┴──┴──┴───┘"
RETURN

END SUB

DEFINT A-Z
SUB cadre (v, h, l, nli, c)
'c est l'intérieur
'le fond écran est bleu

v2 = v

'cadre
COLOR c, bleu

LOCATE v2, h
PRINT STRING$(l + 2, 220)
FOR i = 1 TO nli - 1
v2 = v2 + 1: LOCATE v2, h
PRINT STRING$(l + 2, 219)
NEXT

COLOR , bleu
LOCATE v2 + 1, h: PRINT CHR$(223)

COLOR , noir
LOCATE v + 1
FOR i = 1 TO nli
LOCATE , h + l + 2
PRINT " "
NEXT
LOCATE v2 + 1, h + 1
PRINT STRING$(l + 1, 223)
COLOR 15

END SUB

DEFINT A-Z
SUB cadre1 (v%, h%, l%, nli%, c, c2, c3)
'IF couleur = 0 THEN CALL cadrenb(v%, h%, l%, nli%, c, c2, c3): EXIT SUB
v2 = v
'c est l'intérieur
'c2 est la couleur du fond de la bande
'c3 est la couleur de la bande
COLOR c3, c2
LOCATE v2, h: PRINT CHR$(220); STRING$(l, 220); CHR$(220)
FOR i = 1 TO nli - 1
v2 = v2 + 1
LOCATE v2, h
COLOR , c2: PRINT CHR$(219); : COLOR , c: PRINT SPACE$(l); : COLOR , c2: PRINT CHR$(219)
NEXT
LOCATE v2 + 1, h: PRINT CHR$(223); STRING$(l, 223); CHR$(223)
COLOR blancbrill, noir
END SUB

DEFINT A-Z
SUB cadre3 (v, h, nb, coul)
'inversion de v et h !
LINE (((h - 1) * 8) - 5, ((v - 1) * 14) - 2)-(((h - 1 + nb) * 8) + 5, (v * 14) + 2), coul, B
END SUB

DEFINT A-Z
SUB cadrenb (v%, h%, l%, nli%, c%, c2, c3)
v2 = v
COLOR c3, c2
LOCATE v, h, 0: PRINT "┌"; STRING$(l, 196); "┐"
FOR i = 1 TO nli - 1
v2 = v2 + 1
LOCATE v2, h
COLOR , c2: PRINT "│"; : COLOR , c: PRINT SPACE$(l); : COLOR , c2: PRINT "│"
NEXT
LOCATE v2 + 1, h: PRINT "└"; STRING$(l, 196); "┘"
COLOR blancbrill

END SUB

DEFINT A-Z
SUB calmoy (t$(), moy$(), niveaux())
'29/3/95
debut = 1
FOR Valeur = 1 TO 21
fin = debut + (niveaux(Valeur) - 1)
GOSUB calcul
debut = fin + 1
NEXT

EXIT SUB

calcul:
tt = 0: nt = 0
FOR j = debut TO fin
IF t$(j) <> " " THEN tt = tt + VAL(t$(j)): nt = nt + 1
NEXT j
IF nt = 0 THEN moy$(Valeur) = "" ELSE moy$(Valeur) = LTRIM$(STR$(INT(INT(tt / nt) * 10) / 10))
RETURN

END SUB

DEFINT A-Z
SUB centre (v, coul, ph$)
COLOR coul
LOCATE v, INT(41 - (LEN(ph$) / 2))
PRINT ph$
COLOR 15
END SUB

DEFINT A-Z
SUB chiffreslettres (x, y, t)
DIM c(80), x$(80)
f = 0
'on mémorise la zone quitter
LOCATE 23, 1, 0
COLOR blanc, x
FOR i = 1 TO 80
x$(i) = CHR$(SCREEN(23, i))
c(i) = SCREEN(23, i, 1): IF c(i) > 15 THEN f = 1 'erreur à cause du fond
NEXT

LOCATE 23, 1: PRINT SPACE$(80)
BEEP
IF t = 1 THEN
CALL centre(23, rougeclair, "Des chiffres !")
ELSE
CALL centre(23, rougeclair, "Des lettres !")
END IF
CALL attendre(1)

'on restitue la zone quitter
LOCATE 23, 1
FOR i = 1 TO 80
IF f = 0 THEN
COLOR c(i)
END IF
PRINT x$(i);
NEXT
PRINT
COLOR 15, y
END SUB

DEFINT A-Z
SUB consigne (nl, w$, z$, y$)
CALL titre
l = LEN(w$)
IF LEN(z$) > l THEN l = LEN(z$)
IF LEN(y$) > l THEN l = LEN(y$)

l = l + 6
h = INT(40 - l / 2)

IF eleve <> 0 THEN nl = nl + 1

IF nl = 1 OR nl = 2 THEN
v = 8
ELSEIF nl = 3 THEN
v = 7
ELSEIF nl = 4 THEN
v = 6
END IF

CALL cadre(v, h, l, 4 + (nl * 2), marron)
COLOR , marron
IF eleve <> 0 THEN
CALL centre(v + 3, blancbrill, pre$ + ","): w$ = LCASE$(w$)
CALL centre(v + 5, blancbrill, w$)
CALL centre(v + 7, blancbrill, z$)
CALL centre(v + 10, blancbrill, y$)
ELSE
CALL centre(v + 3, blancbrill, w$)
CALL centre(v + 5, blancbrill, z$)
CALL centre(v + 8, blancbrill, y$)
END IF
CALL entree(noir, noir)
w$ = "": z$ = "": y$ = ""

END SUB

DEFINT A-Z
SUB convertir (z$)
'convertir les . en ,
s = INSTR(1, z$, ".")
IF s <> 0 THEN z$ = MID$(z$, 1, s - 1) + "," + MID$(z$, s + 1)

IF prog = 16 THEN '=== fois
z$ = LTRIM$(z$)
IF LEFT$(z$, 1) = "," THEN z$ = "0" + z$
END IF
END SUB

DEFINT A-Z
SUB convertir2 (no$)
'convertir les , en .
s = INSTR(1, no$, ",")
IF s <> 0 THEN no$ = MID$(no$, 1, s - 1) + "." + MID$(no$, s + 1)
no$ = LTRIM$(no$)
'IF LEFT$(no$, 1) = "." THEN no$ = "0" + no$

END SUB

DEFINT A-Z
SUB entree (y, z)
COLOR 7, y
LOCATE 23, 1: PRINT SPACE$(37) + rt$ + SPACE$(40)
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
r$ = ""
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
r$ = CHR$(13)
CALL attendre(.5)
END IF
LOOP WHILE r$ = ""

COLOR , z

END SUB

DEFINT A-Z
SUB erreur2 ()
CALL centre(23, rougeclair, "Erreur")
CALL attendre(1)
CALL centre(23, 15, SPACE$(7))
END SUB

DEFINT A-Z
SUB exact2 ()
CALL centre(23, jaune, "Exact")
CALL attendre(.5)
CALL centre(23, 15, SPACE$(6))
END SUB

DEFINT A-Z
SUB fleches (v, h, w$(), np, r, coul, drap, v2, h3)
'PRINT v2, h3
'v2 et h3 sont la ligne colonne des fleches
DIM p$(np)

LOCATE , , 0
FOR i = 1 TO np: p$(i) = w$(i): NEXT
l2 = 0
FOR i = 1 TO np
l1 = LEN(p$(i)): IF l2 < l1 THEN l2 = l1
NEXT
FOR i = 1 TO np
p$(i) = p$(i) + SPACE$(l2 - LEN(p$(i)))
NEXT

IF h3 > 0 THEN
COLOR blanc, noir
LOCATE v2, h3: PRINT gg$
END IF

'souris
v_mini = v: v_maxi = v_mini + np - 1
h_mini = h - 1: h_maxi = LEN(p$(1)) + h_mini + 1
'cadre
IF drap = 1 THEN
CALL cadre(v - 1, h - 3, l2 + 4, np + 1, coul)
END IF
COLOR blancbrill, coul

LOCATE v
FOR i = 1 TO np
LOCATE , h - 1: PRINT " "; p$(i); " "
NEXT
vt = v - 1
LOCATE v, h - 1
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(1); " "
COLOR blancbrill, coul
DO
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
IF v_mouse >= v_mini AND v_mouse <= v_maxi THEN
IF h_mouse >= h_mini AND h_mouse <= h_maxi THEN
LOCATE v_mini
FOR i = 1 TO np
LOCATE , h_mini: PRINT " "; p$(i); " "
NEXT
calcul = v_mouse - v_mini + 1
LOCATE v_mouse, h_mini
COLOR coul, blancbrill
PRINT " "; p$(calcul); " "
CALL attendre(.3)
r = calcul
EXIT SUB
ELSE
BEEP
END IF
ELSEIF v_mouse = v2 AND h_mouse = h3 THEN
rr = 72 'fleche haut
souris = 1
CALL attendre(.2)
EXIT DO
ELSEIF v_mouse = v2 AND h_mouse = h3 + 2 THEN
rr = 80 'fleche bas
souris = 1
CALL attendre(.2)
EXIT DO
ELSEIF v_mouse = v2 AND (h_mouse >= h3 + 9 AND h_mouse <= h3 + 11) THEN
rr = 13
souris = 1
CALL attendre(.3)
EXIT DO
ELSE
BEEP
END IF
END IF

LOOP WHILE r$ = ""

IF souris = 0 THEN
IF LEN(r$) < 2 THEN
rr = ASC(r$)
ELSE
rr = ASC(RIGHT$(r$, 1))
END IF
END IF

IF rr = 27 THEN
CALL quitter(noir, coul)
END IF

LOCATE v, h - 1: PRINT " "; p$(v - vt); " "
IF rr = 72 THEN v = v - 1: IF v = vt THEN v = vt + np
IF rr = 80 THEN v = v + 1: IF v = vt + np + 1 THEN v = vt + 1
LOCATE v, h - 1
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(v - vt); " "
COLOR blancbrill, coul
LOOP WHILE rr <> 13
r = v - vt
COLOR blancbrill

END SUB

DEFINT A-Z
SUB flechesmenu (w$(), r, coul)
nm = 21 '===
DIM p$(nm)
CONST gauche = 75, droite = 77, bas = 80, haut = 72
h1 = 6: h3 = 32: h3 = 58

'on met des espaces à la fin
FOR i = 1 TO nm
p$(i) = w$(i)
NEXT
l2 = 0
FOR i = 1 TO nm
l1 = LEN(p$(i)): IF l2 < l1 THEN l2 = l1
NEXT
FOR i = 1 TO nm
p$(i) = p$(i) + SPACE$(l2 - LEN(p$(i)))
NEXT
'+++

h = h1: v = 7
r = 1

DO

IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
LOCATE v, h - 1
PRINT " "; p$(r); " "
COLOR blancbrill, coul

hh = h: vv = v

'fleches
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
POKE &H417, (PEEK(&H417) AND &HBF) 'minus
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
'ligne fleches et entree
IF v_mouse = 22 THEN
IF h_mouse = 33 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 35 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 39 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 46 AND h_mouse <= 48 THEN
'entree
rr = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 3 AND h_mouse <= 15 THEN
'ligne echap et *
rr = 27
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 68 AND h_mouse <= 78 THEN
rr = 42
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
END IF

'lignes noms des activités
IF v_mouse = 7 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 1
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 8
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 15
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF
ELSEIF v_mouse = 9 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 2
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 9
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 16
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSE
BEEP
END IF
ELSEIF v_mouse = 11 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 3
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 10
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 17
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF
ELSEIF v_mouse = 13 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 4
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 11
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 18
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF
ELSEIF v_mouse = 15 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 5
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 12
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 19
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF
ELSEIF v_mouse = 17 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 6
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 13
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 20
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP
END IF

ELSEIF v_mouse = 19 THEN
IF h_mouse >= 6 AND h_mouse <= 24 THEN
GOSUB afficheliste
r = 7
LOCATE v_mouse, 5
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSEIF h_mouse >= 32 AND h_mouse <= 50 THEN
GOSUB afficheliste
r = 14
LOCATE v_mouse, 31
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB
ELSEIF h_mouse >= 57 AND h_mouse <= 76 THEN
GOSUB afficheliste
r = 21
LOCATE v_mouse, 57
IF couleur = 1 THEN COLOR coul, blanc ELSE COLOR noir, blanc
PRINT " "; p$(r); " "
CALL attendre(.5)
EXIT SUB

ELSE
BEEP

END IF

ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 0 AND LEN(r$) < 2 THEN
rr = ASC(r$)
ELSEIF souris = 0 THEN
rr = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE rr

CASE gauche
h = h - 26
IF h < h1 THEN
v = v - 2: h = h3
END IF
IF v < 7 THEN
v = 19
END IF

CASE droite
h = h + 26
IF h > h3 THEN
v = v + 2: h = h1
END IF
IF v > 19 THEN
v = 7
END IF

CASE bas
v = v + 2
IF v > 19 THEN
IF h = h1 THEN
h = h3: v = 7
ELSEIF h = h3 THEN
h = h3: v = 7
ELSEIF h = h3 THEN
h = h1: v = 7
END IF
END IF

CASE haut
v = v - 2
IF v < 7 THEN
IF h = h3 THEN
h = h3: v = 19
ELSEIF h = h3 THEN
h = h1: v = 19
ELSEIF h = h1 THEN
h = h3: v = 19
END IF
END IF

CASE 13
GOSUB calculr
EXIT SUB

CASE 27
r = 0
EXIT SUB

CASE 42, 36, 56, 230, 43
IF eleve <> 0 THEN
'l'étoile
r = 42
EXIT SUB
END IF

END SELECT

COLOR blancbrill, coul
LOCATE vv, hh - 1
PRINT " "; p$(r); " "

GOSUB calculr

LOOP

EXIT SUB

calculr:
IF h = h1 THEN
r = ((v - 7) / 2) + 1
ELSEIF h = h3 THEN
r = ((v - 7) / 2) + 8
ELSEIF h = h3 THEN
r = ((v - 7) / 2) + 15
END IF
RETURN

afficheliste:
'affiche liste exo
h1 = 5: h3 = 31: h3 = 57
COLOR blancbrill
LOCATE 7
FOR i = 1 TO 7
LOCATE , h1: PRINT " "; p$(i); " ": PRINT
NEXT
LOCATE 7
FOR i = 8 TO 14
LOCATE , h3: PRINT " "; p$(i); " ": PRINT
NEXT
LOCATE 7
FOR i = 15 TO 21
LOCATE , h3: PRINT " "; p$(i); " ": PRINT
NEXT
RETURN

END SUB

DEFINT A-Z
SUB getinvi (rr%)
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
LOOP WHILE r$ = ""
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END SUB

DEFINT A-Z
SUB getinvimouse (rr)
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
r$ = CHR$(13)
CALL attendre(.5)
END IF
LOOP WHILE r$ = ""
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))


END SUB

DEFINT A-Z
SUB inputgen (nl%, r$, deb%, fin%, fond%)
'3/4/95
DIM re$(nl + 1)
inpdebut:
IF fond = blanc THEN
COLOR noir, blanc
ELSE
COLOR blancbrill
END IF
r$ = "."
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
ligne = CSRLIN
colon = POS(0)
LOCATE ligne, colon
IF fin% = 57 THEN
PRINT LEFT$(SPACE$(80), nl)
END IF
LOCATE ligne, colon, 1
FOR ii = 1 TO nl + 1
input0:
IF ii <= 0 THEN ii = 1
DO
re$(ii) = INKEY$
LOOP WHILE re$(ii) = ""

IF ASC(re$(ii)) = 27 THEN
CALL quitter(0, fond): r$ = "": EXIT FOR
END IF

IF LEN(re$(ii)) = 2 THEN
z2 = ASC(RIGHT$(re$(ii), 1))
IF ii > 1 AND (z2 = 75 OR z2 = 83 OR z2 = 15) THEN
PRINT CHR$(29); " "; CHR$(29); : ii = ii - 1: z2 = 0
GOTO input0
ELSE
GOTO input0
END IF
END IF

IF deb% = 44 THEN 'fois, moitié
IF re$(ii) = "." OR re$(ii) = "?" OR re$(ii) = ";" THEN
re$(ii) = ","
END IF
END IF

IF ASC(re$(ii)) = 13 THEN EXIT FOR

IF ii > 1 AND ASC(re$(ii)) = 8 THEN
PRINT CHR$(29); " "; CHR$(29); : ii = ii - 1
GOTO input0
ELSEIF ASC(re$(ii)) = 8 THEN
GOTO input0
END IF

IF ASC(re$(ii)) < deb OR ASC(re$(ii)) > fin THEN
IF deb = 48 OR deb = 44 THEN
CALL chiffreslettres(noir, fond, 1): r$ = "": EXIT FOR'problème couleur avec tableau
ELSE
CALL chiffreslettres(noir, fond, 2): r$ = "": EXIT FOR
END IF
END IF

IF (prog% = 4 AND ni% = 3) AND (re$(ii) = "," OR re$(ii) = ".") THEN
'lettres => chiffres et lettres ===
posi = POS(0)
li = CSRLIN
COLOR , noir: LOCATE , , 0
LOCATE 23, 1: PRINT SPACE$(80)
BEEP: CALL centre(23, rougeclair, "Tape le mot 'virgule'")
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
COLOR noir, blanc
LOCATE li, posi, 1
GOTO input0
END IF

IF ii = nl + 1 THEN BEEP: GOTO input0

PRINT re$(ii);
NEXT ii
IF r$ = "" THEN LOCATE ligne, colon: GOTO inpdebut
PRINT
r$ = "": FOR JJ = 1 TO ii - 1: r$ = r$ + re$(JJ): NEXT
r$ = LTRIM$(r$): r$ = RTRIM$(r$)
IF r$ = "" AND prog <> 20 THEN 'mémoire ===
BEEP: LOCATE ligne, colon: GOTO inpdebut
END IF
LOCATE , , 0

END SUB

DEFINT A-Z
SUB ligne23 (x, y, z!)
IF z! > 0 THEN CALL attendre(z!)
COLOR , x
LOCATE 23, 1, 0: PRINT SPACE$(80): LOCATE 23
COLOR , y
END SUB

DEFINT A-Z
SUB niv (limit, xx)
COLOR noir, vert
LOCATE 21, 2: PRINT " Niveau"; ni
LOCATE 21, 76: PRINT " "
IF limit + 1 - xx > 9 THEN LOCATE 21, 76 ELSE LOCATE 21, 77
PRINT limit + 1 - xx
COLOR blancbrill, bleu
END SUB

DEFINT A-Z
SUB Niveau (ni, np)
CALL titre
DIM p$(4)
CALL cadre(7, 25, 30, 2, vert)
COLOR , vert
CALL centre(8, blancbrill, "Niveau de difficulté")

p$(1) = "1": p$(2) = "2": p$(3) = "3": p$(4) = "4"
CALL fleches(13, 40, p$(), np, ni, rouge, 1, 23, 35)
END SUB

DEFINT A-Z
SUB ouinon (r$)
h = POS(0)
v = CSRLIN

DIM regs AS RegType
regs.ax = &HF00
INTERRUPT &H10, regs, regs ' &H10 renvoie informations
' sur vidéo.
sWidth = (regs.ax AND &HFF00) \ 256 ' Octet fort de AX (AH).
sMode = regs.ax AND &HFF ' Octet faible de AX (AL).

SELECT CASE sMode ' Fait correspondre numéros
CASE 3 ' de mode vidéo MS-DOS et
sMode = 0 ' modes affichage Basic.
CASE 16
sMode = 9
MouseInit
END SELECT

LOCATE v, h
COLOR blanc: PRINT "["; : COLOR jaune: PRINT "O"; : COLOR blanc: PRINT "]ui ou ["; : COLOR jaune: PRINT "N"; : COLOR blanc: PRINT "]on ?"

MouseShow
LOCATE v, h
COLOR blanc: PRINT "["; : COLOR jaune: PRINT "O"; : COLOR blanc: PRINT "]ui ou ["; : COLOR jaune: PRINT "N"; : COLOR blanc: PRINT "]on ?"

DO
r$ = ""
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF sMode = 9 THEN
'matrice 14 x 8 = transforme en coord écran
v_mouse = INT(v_mouse / 14) + 1
h_mouse = INT(h_mouse / 8) + 1
END IF
IF lButton THEN
IF v_mouse = v AND (h_mouse >= h AND h_mouse <= h + 5) THEN
r$ = "o"
CALL attendre(.3)
ELSEIF v_mouse = v AND (h_mouse >= h + 10 AND h_mouse <= h + 14) THEN
r$ = "n"
CALL attendre(.3)
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

r$ = UCASE$(r$)
LOOP UNTIL r$ = "O" OR r$ = "N" OR r$ = CHR$(27) OR r$ = CHR$(13)

END SUB

DEFINT A-Z
SUB place (v, h, p$, c)
COLOR c
LOCATE v, h: PRINT p$

END SUB

DEFINT A-Z
SUB quitter (x, y)
'19/01/95 ok
DIM c(80), x$(80)
MouseHide
f = 0
'on mémorise la zone quitter
LOCATE 23, 1, 0
COLOR blanc, x
FOR i = 1 TO 80
x$(i) = CHR$(SCREEN(23, i))
c(i) = SCREEN(23, i, 1): IF c(i) > 15 THEN f = 1 'erreur à cause du fond
NEXT
LOCATE 23, 1: PRINT SPACE$(80)
LOCATE 23, 28
COLOR blanc: BEEP: PRINT "Quitter ";
CALL ouinon(r$)
IF r$ = "O" THEN COLOR , 0: CLS : RUN "exo_ma2"

'on restitue la zone quitter
LOCATE 23, 1
FOR i = 1 TO 80
IF f = 0 THEN
COLOR c(i)
END IF
PRINT x$(i);
NEXT
PRINT
COLOR 15, y
END SUB

DEFINT A-Z
SUB resultats (re, ni, nbniv)
tit$ = titr$
titr$ = "resultats"
CALL titre

w! = LEN(tit$) / 2
IF w! = INT(LEN(tit$) / 2) THEN n = 4 ELSE n = 2
CALL cadre(5, 38 - INT(LEN(tit$) / 2), INT(LEN(tit$)) + n, 2, blanc)
COLOR , blanc
CALL centre(6, noir, tit$)
COLOR , bleu

IF re > 8 THEN
cc = vertclair: z$ = "Acquis"
ELSEIF re > 4 AND re < 9 THEN
cc = jaune: z$ = "En cours d'acquisition"
ELSE
cc = rougeclair: z$ = "Non acquis"
END IF

IF nbniv <> 1 THEN
s$ = " au niveau" + RTRIM$(STR$(ni))
ELSE
s$ = ""
END IF

CALL centre(10, cc, z$ + s$)
CALL cadre(12, 20, 40, 2, rouge)
LOCATE 13
i2 = 0
FOR i = 1 TO re
LOCATE , 21 + i2: PRINT "████"; '219
i2 = i2 + 4
NEXT
COLOR noir, noir
FOR i = re + 1 TO 10
LOCATE , 21 + i2: PRINT " ";
i2 = i2 + 4
NEXT
PRINT
COLOR , bleu
CALL centre(16, 15, "Pourcentage de réussite :" + STR$(re * 10) + " %")
CALL centre(18, 15, "(" + LTRIM$(STR$(re)) + " sur 10)")

COLOR blancbrill
END SUB

DEFINT A-Z
SUB solution (sol$)
BEEP
COLOR , 0
CALL centre(23, 12, "Solution : " + LTRIM$(sol$))
COLOR 15
END SUB

DEFINT A-Z
SUB tableauexo (p$())
'tableau des exercices
CALL cadre(5, 2, 75, 16, rouge)
COLOR , bleu
LOCATE 22, 3: PRINT "["; : COLOR jaune: PRINT "Echap"; : COLOR blancbrill: PRINT "] = Fin"
CALL centre(22, blanc, gg2$)
IF eleve <> 0 THEN
COLOR blancbrill
LOCATE 22, 68: PRINT "["; : COLOR jaune: PRINT "*"; : COLOR blancbrill: PRINT "] = Bilan"
END IF


l3$ = SPACE$(24) + "│" + SPACE$(25) + "│" + SPACE$(23)
l4$ = STRING$(24, "─") + "┼" + STRING$(25, "─") + "┼" + STRING$(23, "─")
l5$ = STRING$(24, "─") + "┬" + STRING$(25, "─") + "┬" + STRING$(23, "─")
l6$ = STRING$(24, "─") + "┴" + STRING$(25, "─") + "┴" + STRING$(23, "─")

COLOR blanc, rouge
LOCATE 6
LOCATE , 3: PRINT l5$
'LOCATE , 3: PRINT l3$
FOR i = 1 TO 6
LOCATE , 3: PRINT l3$
LOCATE , 3: PRINT l4$
NEXT
LOCATE , 3: PRINT l3$
LOCATE , 3: PRINT l6$

'affiche liste exo
h1 = 6: h3 = 32: h3 = 58
COLOR blancbrill
LOCATE 7
FOR i = 1 TO 7
LOCATE , h1: PRINT p$(i): PRINT
NEXT
LOCATE 7
FOR i = 8 TO 14
LOCATE , h3: PRINT p$(i): PRINT
NEXT
LOCATE 7
FOR i = 15 TO 21
LOCATE , h3: PRINT p$(i): PRINT
NEXT


END SUB

DEFINT A-Z
SUB titre ()
MouseShow
w$ = titr$
COLOR , noir, noir: CLS
FOR i = 1 TO LEN(w$)
IF MID$(w$, i, 1) = "é" OR MID$(w$, i, 1) = "è" THEN
w$ = MID$(w$, 1, i - 1) + "E" + MID$(w$, i + 1)
END IF
NEXT
FOR i = 1 TO LEN(w$)
IF MID$(w$, i, 1) = "à" THEN
w$ = MID$(w$, 1, i - 1) + "A" + MID$(w$, i + 1)
END IF
NEXT

COLOR , vert
LOCATE 2, 1: PRINT SPACE$(80)
CALL centre(2, noir, UCASE$(w$))
LOCATE 21, 1: PRINT SPACE$(80)
VIEW PRINT 3 TO 20: COLOR blancbrill, bleu: CLS 2: VIEW PRINT

END SUB

DEFINT A-Z
SUB titre2 (titr$)
COLOR , noir: CLS
w$ = titr$
FOR i = 1 TO LEN(w$)
IF MID$(w$, i, 1) = "é" OR MID$(w$, i, 1) = "è" THEN
w$ = MID$(w$, 1, i - 1) + "E" + MID$(w$, i + 1)
END IF
NEXT
LINE (0, 14)-(640, 27), vert, BF
CALL centre(2, jaune, " " + UCASE$(w$) + " ")
LINE (0, 28)-(639, 279), bleu, BF
LINE (0, 279)-(640, 292), vert, BF
COLOR blancbrill

END SUB
 

 

DECLARE SUB niv (limit%, xx%)
DECLARE SUB divi (reponse$, a&, b&, er%, v%, h%, cd%, cd2%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, coul%)
DECLARE SUB soust (reponse$, a&, b&, cc%, v%, h%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, fond%)
DECLARE SUB add (reponse$, a&(), n%, cc%, v%, h%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, fond%)
DECLARE SUB fleches (v%, h%, w$(), np%, r%, coul%, drap%, v2%, h3%)
DECLARE SUB MouseHide ()
DECLARE SUB getinvimouse (rr%)
DECLARE SUB consigne (nl%, w$, z$, y$)
DECLARE SUB chiflet (re%, ni%, mot$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB cadre3 (v%, h%, nb%, coul%)
DECLARE SUB titre2 (titr$)
DECLARE SUB cadrenb (v%, h%, l%, nli%, c%, c2%, c3%)
DECLARE SUB cadre1 (v%, h%, l%, nli%, c%, c2%, c3%)
DECLARE SUB divi4 (re%, ni%, rt$, li$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB place (v%, h%, p$, c%)
DECLARE SUB quitter (x%, y%)
DECLARE SUB inputgen (nl%, r$, deb%, fin%, z%)
DECLARE SUB entree (y%, z%)
DECLARE SUB getinvi (rr%)
DECLARE SUB attendre (tx!)
DECLARE SUB titre ()
DECLARE SUB Niveau (ni%, np%)
DECLARE SUB ligne23 (x%, y%, z!)
DECLARE SUB centre (v%, coul%, ph$)
DECLARE SUB solution (sol$)
DECLARE SUB erreur2 ()
DECLARE SUB exact2 ()
DECLARE SUB chiffreslettres (x%, y%, t%)
DECLARE SUB trouvemot (m$, m$(), nm%)
DECLARE SUB soustraction2 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB soustdecimal (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB addecimal (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'EXERCICES 2 MATH COLLEGE
'5/5/96
'Daniel CLERC
'version 1.0


DEFINT A-Z
SUB additions (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'22/3/95
DIM a&(9)

principalad:
re = 0: cc = 0: f = 0: ret = 0

CALL Niveau(ni, 3)
SELECT CASE ni
CASE 1
c = 3: n = 3
CASE 2
c = 4: n = 4
CASE 3
'décimaux
CALL addecimal(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
EXIT SUB
END SELECT

FOR no = 1 TO 5 '++++++++++++

CALL titre
CALL niv(5, no)

'tirage
s& = 0

DO
a&(1) = INT(RND * (10 ^ c))
LOOP WHILE a&(1) < 10 ^ (c - 1)
FOR i = 2 TO n
IF i = 3 THEN
a&(i) = INT(RND * (10 ^ (c - 1))) + 50
ELSE
a&(i) = INT(RND * (10 ^ c)) + 1
END IF
NEXT i

CALL cadre(7, 25, 30, n + 6, rouge)
COLOR , rouge
CALL add(reponse$, a&(), n%, cc%, 9, 43, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, rouge%)

'resultats
LOCATE 23: COLOR , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
LOCATE 23, 32
COLOR rougeclair
PRINT "Tu as fait"; cc; "faute"; : IF cc > 1 THEN PRINT "s";
PRINT "."
IF cc > 4 AND ni > 1 AND no <> 5 THEN
CALL attendre(.7)
BEEP: CALL centre(23, rougeclair, "Tu vas changer de niveau.")
CALL getinvimouse(w)
f = 1
EXIT FOR
END IF
END IF
CALL getinvimouse(w)
cc = 0
NEXT no

IF f = 1 THEN GOTO principalad
CALL resultats(re, ni, 3)

END SUB

DEFINT A-Z
SUB chiflet (re, ni, mot$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'28/10/96
DIM nr(5), z(10), nb$(18), m$(50), m2$(50), m3$(50), m4$(50)
DIM a1$(24), b1$(24), b2$(24)
' lettre -> chiflet
a1$(1) = "62,01": b1$(1) = "SOIXANTE DEUX VIRGULE ZERO UN CENTIEME"
a1$(2) = "40,23": b1$(2) = "QUARANTE VIRGULE VINGT TROIS CENTIEMES"
a1$(3) = "35,01": b1$(3) = "TRENTE CINQ VIRGULE ZERO UN CENTIEME"
a1$(4) = "25,5": b1$(4) = "VINGT CINQ VIRGULE CINQ DIXIEMES"
a1$(5) = "50,36": b1$(5) = "CINQUANTE VIRGULE TRENTE SIX CENTIEMES"
a1$(6) = "15,5": b1$(6) = "QUINZE VIRGULE CINQ DIXIEMES"
a1$(7) = "40,04": b1$(7) = "QUARANTE VIRGULE ZERO QUATRE CENTIEMES"
a1$(8) = "10,1": b1$(8) = "DIX VIRGULE UN DIXIEME"
a1$(9) = "1 007,32": b1$(9) = "MILLE SEPT VIRGULE TRENTE DEUX CENTIEMES"
a1$(10) = "5 008,7": b1$(10) = "CINQ MILLE HUIT VIRGULE SEPT DIXIEMES"
a1$(11) = "105,02": b1$(11) = "CENT CINQ VIRGULE ZERO DEUX CENTIEMES"
a1$(12) = "1 000,005": b1$(12) = "MILLE VIRGULE ZERO ZERO CINQ MILLIEMES"
a1$(13) = "12 001,2": b1$(13) = "DOUZE MILLE UN VIRGULE DEUX DIXIEMES"
a1$(14) = "0,052": b1$(14) = "ZERO VIRGULE ZERO CINQUANTE DEUX MILLIEMES"
a1$(15) = "1 000,68": b1$(15) = "MILLE VIRGULE SOIXANTE HUIT CENTIEMES"
a1$(16) = "100 008,9": b1$(16) = "CENT MILLE HUIT VIRGULE NEUF DIXIEMES"
a1$(17) = "1 000 000,4": b1$(17) = "UN MILLION VIRGULE QUATRE DIXIEMES"
a1$(18) = "105,35": b1$(18) = "CENT CINQ VIRGULE TRENTE CINQ CENTIEMES"
a1$(19) = "8,025": b1$(19) = "HUIT VIRGULE ZERO VINGT CINQ MILLIEMES"
a1$(20) = "0,008": b1$(20) = "ZERO VIRGULE ZERO ZERO HUIT MILLIEMES"
a1$(21) = "30,125": b1$(21) = "TRENTE VIRGULE CENT VINGT CINQ MILLIEMES"
a1$(22) = "3 000,05": b1$(22) = "TROIS MILLE VIRGULE ZERO CINQ CENTIEMES"
a1$(23) = "5 000 000,3": b1$(23) = "CINQ MILLIONS VIRGULE TROIS DIXIEMES"
a1$(24) = "120,003": b1$(24) = "CENT VINGT VIRGULE ZERO ZERO TROIS MILLIEMES"
'idem
b2$(1) = "soixante deux virgule zéro un centième"
b2$(2) = "quarante virgule vingt trois centièmes"
b2$(3) = "trente cinq virgule zéro un centième"
b2$(4) = "vingt cinq virgule cinq dixièmes"
b2$(5) = "cinquante virgule trente six centièmes"
b2$(6) = "quinze virgule cinq dixièmes"
b2$(7) = "quarante virgule zéro quatre centièmes"
b2$(8) = "dix virgule un dixième"
b2$(9) = "mille sept virgule trente deux centièmes"
b2$(10) = "cinq mille huit virgule sept dixièmes"
b2$(11) = "cent cinq virgule zéro deux centièmes"
b2$(12) = "mille virgule zéro zéro cinq millièmes"
b2$(13) = "douze mille un virgule deux dixièmes"
b2$(14) = "zéro virgule zéro cinquante deux millièmes"
b2$(15) = "mille virgule soixante huit centièmes"
b2$(16) = "cent mille huit virgule neuf dixièmes"
b2$(17) = "un million virgule quatre dixièmes"
b2$(18) = "cent cinq virgule trente cinq centièmes"
b2$(19) = "huit virgule zéro vingt cinq millièmes"
b2$(20) = "zéro virgule zéro zéro huit millièmes"
b2$(21) = "trente virgule cent vingt cinq millièmes"
b2$(22) = "trois mille virgule zéro cinq centièmes"
b2$(23) = "cinq millions virgule trois dixièmes"
b2$(24) = "cent vingt virgule zéro zéro trois millièmes"


l2$ = SPACE$(71)
l$ = STRING$(40, 196)
FOR i = 1 TO 24: b1$(i) = LCASE$(b1$(i)): NEXT
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &HBF) 'minus
DEF SEG

re = 0
nr = 0: FOR j = 1 TO 5: nr(j) = 0: NEXT
MouseHide

COLOR jaune, bleu: CLS
LOCATE 2, 3: PRINT "Rappel"
CALL cadre(3, 2, 75, 18, rouge)
COLOR , rouge
h = 20
CALL place(6, 7, "Exemples :", vertclair)
CALL place(8, h, "23,06", cyanclair)
CALL place(10, h, "vingt trois virgule zéro six centièmes", jaune)
CALL place(12, h, "106,003", cyanclair)
CALL place(14, h, "cent six virgule zéro zéro trois millièmes", jaune)
CALL place(16, h, "1000,1", cyanclair)
CALL place(18, h, "mille virgule un dixième", jaune)
CALL entree(bleu, bleu)

FOR ii = 1 TO 5 '++++++++++++++++
c = 0
COLOR , noir: CLS
COLOR , vert
LOCATE 2, 1: PRINT SPACE$(80)
CALL centre(2, noir, UCASE$(titr$))
LOCATE 20, 1: PRINT SPACE$(80)
VIEW PRINT 3 TO 19: COLOR blancbrill, bleu: CLS 2: VIEW PRINT

COLOR noir%, vert%
LOCATE 20, 2: PRINT " Niveau"; ni%
LOCATE 20, 77
PRINT 6 - ii%

COLOR blancbrill, noir
CALL centre(22, blanc, "Tape ce nombre en lettres")

DO
f = 0
z(ii) = INT(RND * 24) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
nr = z(ii)

CALL cadre(7, 30, 20, 4, rouge)
COLOR , rouge
CALL centre(9, jaune, a1$(nr)): COLOR blancbrill, bleu

r$ = ""

chiflet1:
CALL cadre(15, 4, 72, 2, blanc%)
COLOR noir%, blanc%
LOCATE 16, 8: PRINT "_"
LOCATE 16, 8

CALL inputgen(55, r$, 32, 155, blanc)

b$ = LCASE$(r$)

COLOR blancbrill, noir: LOCATE 21
FOR i = 1 TO 3: PRINT SPACE$(80): NEXT

'epure
l = LEN(b$)
IF l >= 2 THEN
FOR ik = 1 TO LEN(b$)
IF MID$(b$, ik, 1) = "-" THEN
b$ = MID$(b$, 1, ik - 1) + " " + MID$(b$, ik + 1)
END IF
NEXT

ik = 1
DO
IF ASC(MID$(b$, ik, 1)) = 32 THEN
IF ASC(MID$(b$, ik + 1, 1)) = 32 THEN
b$ = MID$(b$, 1, ik) + MID$(b$, ik + 2): l = l - 1: ik = ik - 1
END IF
END IF
ik = ik + 1
LOOP WHILE ik <> l
END IF

IF ASC(b$) < 65 THEN
CALL chiffreslettres(noir, bleu, 2)
GOTO chiflet1
END IF

IF b$ <> b1$(nr) AND b$ <> b2$(nr) THEN
n2$ = b2$(nr)
GOSUB rescl
GOTO chiflet1
END IF

CALL centre(22, jaune, "Exact")
CALL attendre(1)
CALL centre(22, 15, SPACE$(6))

IF c = 0 THEN
re = re + 2
ELSEIF c = 1 THEN
re = re + 1
END IF

NEXT ii '+++++++++++++

CALL resultats(re, ni, 3)

EXIT SUB

rescl:
c = c + 1
IF c > 2 THEN
BEEP
LOCATE 21: PRINT SPACE$(80): PRINT SPACE$(80)
CALL centre(22, rougeclair, "Solution : " + LTRIM$(b2$(nr)))
ELSE
LOCATE 21: PRINT "Ta réponse : "; : COLOR blancbrill%: PRINT b$
COLOR rougeclair
LOCATE 22
CALL trouvemot(b$, m$(), nm): b$ = MID$(b$, 1, LEN(b$) - 1)
CALL trouvemot(n2$, m2$(), nm2): n2$ = MID$(n2$, 1, LEN(n2$) - 1)
IF nm < nm2 THEN PRINT "Il manque des mots...": CALL attendre(.5)
IF nm > nm2 THEN PRINT "Il y a trop de mots...": CALL attendre(.5)
z = 0
FOR j = 1 TO nm
f = 0
FOR i = 1 TO 45 '=== 45 mot$()
IF mot$(i) = m$(j) THEN f = 1: EXIT FOR
NEXT i
IF f = 0 THEN z = z + 1: m3$(z) = m$(j)
NEXT j
COLOR jaune%
LOCATE 23
IF z = 0 THEN
z2 = 0
FOR i = 1 TO nm2
IF m2$(i) <> m$(i) THEN z2 = z2 + 1: m4$(z2) = m2$(i)
NEXT
IF z2 <> 0 THEN PRINT "Aide : "; : COLOR rougeclair: FOR i = 1 TO z2: PRINT m4$(i); ", "; : NEXT: PRINT CHR$(29); CHR$(29); " "
ELSEIF z = 1 THEN
PRINT "Mot mal orthographié : "; : COLOR rougeclair: PRINT m3$(1)
ELSE
w$ = "": FOR i = 1 TO z: w$ = w$ + m3$(i) + ", ": NEXT
IF LEN(w$) < 55 THEN
PRINT "Mots mal orthographiés : "; : COLOR rougeclair
FOR i = 1 TO z: PRINT m3$(i); ", "; : NEXT: PRINT CHR$(29); CHR$(29); " "
END IF
END IF
CALL attendre(1.5)
END IF
RETURN

END SUB

DEFINT A-Z
SUB cmental (re, ni, rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
DIM re$(25), p$(6)
'11/3/95
re = 0

CALL Niveau(ni, 3)

'série
op = 0

FOR ij = 1 TO 10 '+++++++++++++
CALL titre
CALL niv(10, ij)

DO
op2 = INT(RND * 4) + 1
LOOP WHILE op = op2
op = op2

DO
SELECT CASE op
CASE 1, 2
'_add & sous_
IF ni = 1 THEN
m1 = 70: m2 = 100
ELSEIF ni = 2 THEN
m1 = 200: m2 = 200
ELSE
m1 = 300: m2 = 500
END IF

cm0:
n1 = INT(RND * m1) + 1
IF ni = 1 AND n1 < 40 THEN GOTO cm0
IF ni = 2 AND n1 < 100 THEN GOTO cm0
IF ni = 3 AND n1 < 150 THEN GOTO cm0
cm1:
n2 = INT(RND * m2) + 1
IF ni = 1 AND n2 < 20 THEN GOTO cm1
IF ni = 2 AND n2 < 40 THEN GOTO cm1
IF ni = 3 AND n2 < 80 THEN GOTO cm1

IF op = 2 AND (n1 < n2) THEN GOTO cm0

CASE 3
'multiplication
IF ni = 1 THEN
m1 = 20: m2 = 10
ELSEIF ni = 2 THEN
m1 = 25: m2 = 15
ELSE
m1 = 30: m2 = 20
END IF
cm2:
n1 = INT(RND * m1) + 1
IF ni = 1 AND n1 < 10 THEN GOTO cm2
IF ni = 2 AND n1 < 12 THEN GOTO cm2
IF ni = 3 AND n1 < 15 THEN GOTO cm2
cm3:
n2 = INT(RND * m2) + 1
IF ni = 1 AND n2 < 4 THEN GOTO cm3
IF ni = 2 AND n2 < 8 THEN GOTO cm3
IF ni = 3 AND n2 < 12 THEN GOTO cm3

CASE 4
'division
IF ni = 1 THEN
m1 = 5: m2 = 5
ELSEIF ni = 2 THEN
m1 = 10: m2 = 8
ELSE
m1 = 15: m2 = 10
END IF
cm5:
n1 = INT(RND * m1) + 1
IF ni = 2 AND n1 < 5 THEN GOTO cm5
IF ni = 3 AND n1 < 8 THEN GOTO cm5
cm6:
n2 = INT(RND * m2) + 1
IF ni = 2 AND n2 < 4 THEN GOTO cm6
IF ni = 3 AND n2 < 5 THEN GOTO cm6

END SELECT

LOOP WHILE n1 = n2

CALL cadre(7, 22, 16, 2, marron)
COLOR blancbrill, marron
LOCATE 8, 24
SELECT CASE op

CASE 1
sol = n1 + n2: a = n1: op$ = "+"
PRINT "Addition"
CASE 2
sol = n1 - n2: a = n1: op$ = "-"
PRINT "Soustraction"
CASE 3
sol = n1 * n2: a = n1: op$ = "x"
PRINT "Multiplication"
CASE 4
sol = n1: a = n1 * n2: op$ = ":"
PRINT "Division"
END SELECT

CALL cadre(10, 22, 16, 4, blanc)
LOCATE 12, 24
COLOR noir, blanc: PRINT a; op$; n2

bon = INT(RND * 5) + 1
p$(bon) = LTRIM$(STR$(sol))
plus = sol + INT(RND * sol / 3): IF plus = sol THEN plus = plus + 1
plus2 = sol + INT(RND * sol / 4): IF plus2 = sol THEN plus2 = plus2 + 1
IF plus = plus2 THEN plus = plus + 1
moins = sol - INT(RND * sol / 3): IF moins = sol THEN moins = moins - 1
moins2 = sol - INT(RND * sol / 4): IF moins2 = sol THEN moins2 = moins2 - 1
IF moins = moins2 THEN moins = moins - 1
IF moins < 0 THEN moins = 0
plus3 = plus2 + 2

IF bon = 1 THEN
p$(2) = LTRIM$(STR$(plus))
p$(3) = LTRIM$(STR$(moins))
p$(4) = LTRIM$(STR$(plus2))
p$(5) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

ELSEIF bon = 2 THEN
p$(1) = LTRIM$(STR$(moins))
p$(4) = LTRIM$(STR$(plus))
p$(3) = LTRIM$(STR$(plus2))
p$(5) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

ELSEIF bon = 3 THEN
p$(5) = LTRIM$(STR$(moins))
p$(4) = LTRIM$(STR$(plus))
p$(2) = LTRIM$(STR$(plus2))
p$(1) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

ELSEIF bon = 4 THEN
p$(5) = LTRIM$(STR$(moins))
p$(1) = LTRIM$(STR$(plus))
p$(3) = LTRIM$(STR$(plus2))
p$(2) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

ELSE
p$(2) = LTRIM$(STR$(moins))
p$(3) = LTRIM$(STR$(plus))
p$(1) = LTRIM$(STR$(plus2))
p$(4) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))
END IF

DO
CALL cadre(7, 48, 5, 7, rouge)
CALL fleches(8, 50, p$(), 6, r, rouge, 0, 23, 45)
CALL ligne23(noir, noir, 0)
IF r = bon THEN
CALL exact2
IF c = 0 THEN re = re + 1
c = 0
EXIT DO
ELSE
c = c + 1
IF c > 1 THEN
CALL solution(STR$(sol))
CALL attendre(2)
LOCATE 23, 1: PRINT SPACE$(80)
ELSE
CALL erreur2
END IF
END IF
LOOP
NEXT ij '+++++++++

CALL resultats(re, ni, 3)

END SUB

DEFINT A-Z
SUB divisions (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'DIM r$(9), r(9), q(9), st(9), st$(9), m(9), m$(9), p(5)
'4/5/95

l$ = STRING$(10, 196)

princdivi:
re = 0: f = 0
CALL Niveau(ni, 4)
SELECT CASE ni
CASE 1
n1 = 2: n2 = 1
CASE 2
n1 = 3: n2 = 1
CASE 3
n1 = 3: n2 = 2
CASE 4
CALL divi4(re%, ni%, rt$, li$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
EXIT SUB
END SELECT

FOR no = 1 TO 5 '++++++++++++++++
IF ni = 2 AND no = 5 THEN n1 = 4
IF ni = 3 AND no = 5 THEN n1 = 4

CALL titre
IF no = 1 THEN
CALL cadre(11, 20, 40, 2, marron)
COLOR , marron
CALL centre(12, blancbrill, "Tu calculeras les retenues mentalement.")
CALL attendre(2)
CALL titre
END IF

CALL niv(5, no)

'tirage
DO
DO
b& = INT(RND * 10 ^ n2)
LOOP WHILE b& = 0 OR b& = 10 ^ n2

DO
q& = INT(RND * 10 ^ (n1 - n2))
LOOP WHILE q& = 0 OR q& = 10 ^ (n1 - n2)

WHILE q& < 10 ^ (n1 - n2 - 1)
q& = q& * 10
WEND

IF ni = 1 THEN
a& = q& * b&
ELSE
IF b& >= 10 THEN
ajout = 10
ELSE
ajout = b&
END IF
a& = q& * b& + INT(RND * ajout) 'pour opération avec reste
END IF

LOOP WHILE LEN(LTRIM$(STR$(a&))) <> n1

CALL cadre(7, 23, 34, 11, rouge)
COLOR , rouge
v = 10: h = 40
CALL divi(reponse$, a&, b&, cc%, v, h, cd%, cd2%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, rouge)

IF no = 1 THEN
COLOR vertclair
LOCATE v, 24: PRINT "Dividende "; CHR$(26)
LOCATE v, 47: PRINT CHR$(27); " Diviseur"
IF cd > 1 THEN
LOCATE (v + 2) + (cd2 - 2), 27: PRINT "Reste "; CHR$(26)
ELSE
LOCATE v + 3, 28: PRINT "Reste "; CHR$(26)
END IF
LOCATE v + 2, 47: PRINT CHR$(27); " Quotient"
END IF

'result
COLOR , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc < 3 THEN re = re + 1
LOCATE 23, 32
COLOR rougeclair
PRINT "Tu as fait"; cc; "faute"; : IF cc > 1 THEN PRINT "s";
PRINT "."
IF cc > 6 AND ni > 1 AND no <> 5 THEN
CALL attendre(.7)
BEEP: CALL centre(23, rougeclair, "Tu vas changer de niveau.")
CALL getinvimouse(w)
f = 1: EXIT FOR
END IF
END IF
CALL getinvimouse(w)

NEXT no '+++++++++++++++++

IF f = 1 THEN GOTO princdivi

CALL resultats(re, ni, 3)

END SUB

DEFINT A-Z
SUB encadre (re%, ni%, rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
DIM re$(10), p$(5)
'10/5/96
cc = 0: re = 0
p$(1) = "10 près": p$(2) = "100 près": p$(3) = "1000 près": p$(4) = "10000 près"
p$(5) = "100000 près"

COLOR jaune, bleu
CLS
LOCATE 2, 23: PRINT "RAPPEL"
CALL cadre(3, 22, 36, 18, rouge)
COLOR , rouge
h = 28
CALL place(6, h, "Encadrement à " + p$(3), cyanclair)
CALL place(8, h, "Un nombre : 18765", jaune)
CALL place(11, h, "Valeur par DEFAUT :", vertclair)
CALL place(13, h, "18000", jaune)
CALL place(16, h, "Valeur par EXCES :", vertclair)
CALL place(18, h, "19000", jaune)
CALL entree(bleu, bleu)

ct = 0
'niveau
CALL Niveau(ni, 2)

CALL titre

FOR ii = 1 TO 5 '++++++++++
MouseHide
CALL niv(5, ii)
DO
SELECT CASE ni
CASE 1
'10 ou 100 ou 1000
puis = INT(RND * 3) + 1

CASE 2
'1000 ou 10000
puis = INT(RND * 3) + 3

END SELECT

x = INT(RND * 2) + 1

DO
nombre& = INT(RND * 10 ^ (puis + x)) + 1
LOOP WHILE nombre& < 10 ^ (puis + (x - 1))

no$ = LTRIM$(STR$(nombre&))
LOOP WHILE RIGHT$(no$, 1) = "0"

LOCATE 6, 1: PRINT SPACE$(80)
CALL centre(6, jaune, "Encadrement à " + p$(puis))
IF LEN(no$) / 2 <> INT(LEN(no$) / 2) THEN h = 7: h1 = 36 ELSE h = 8: h1 = 36
'LOCATE 8: FOR i = 1 TO 3: LOCATE , 30: PRINT SPACE$(20): LOCATE , 30: PRINT SPACE$(20): NEXT
CALL cadre(8, 36, 8, 2, rouge)
COLOR , rouge
CALL centre(9, vertclair, no$)
COLOR , bleu
COLOR vertclair: LOCATE 12, 27: PRINT "Défaut"
CALL cadre(13, 22, 14, 4, blanc)
COLOR vertclair, bleu: LOCATE 12, 49: PRINT "Excès"
CALL cadre(13, 44, 14, 4, blanc)
rb& = INT(nombre& / 10 ^ puis) * (10 ^ puis)
h = 25: GOSUB encadresaisie

rb& = rb& + 10 ^ puis
h = 47: GOSUB encadresaisie
CALL attendre(.5)

NEXT ii '++++++++++

CALL resultats(re, ni, 2)

EXIT SUB

encadresaisie:
DO
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")
COLOR noir, blanc
LOCATE 15, h: PRINT CHR$(16); " ";

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

CALL inputgen(8, r$, 48, 57, blanc)
de& = VAL(r$)
COLOR , noir
CALL centre(23, 0, SPACE$(80))

IF de& <> rb& THEN
cc = cc + 1
COLOR rougeclair
IF cc > 2 THEN
CALL solution(STR$(rb&))
CALL attendre(1.5)
ELSE

IF LEN(STR$(de&)) <> LEN(STR$(rb&)) THEN
CALL centre(23, rougeclair, "Il faut" + STR$(LEN(STR$(rb&)) - 1) + " chiffres.")
ELSEIF RIGHT$(STR$(de&), puis) <> RIGHT$("000000", puis) THEN
CALL centre(23, rougeclair, "Erreur dans les zéros.")
ELSEIF de& < rb& THEN
CALL centre(23, rougeclair, "Trop petit...")
ELSE
CALL centre(23, rougeclair, "Trop grand...")
END IF
CALL attendre(2)
CALL centre(23, 0, SPACE$(80))
END IF
ELSE
COLOR blanc, blanc
LOCATE 15, h: PRINT " "
COLOR , noir
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
END IF
LOOP

RETURN

END SUB

DEFINT A-Z
SUB fractions (re, ni, rt$, gg$, pre$, titr$, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill, couleur)
DIM z(10), z2(10), zz(10), a(10)
'12/6/96
titr$ = "fractions"
coef1! = .72: coef2! = .72
CONST pi = 3.141592653589#
re! = 0
a(1) = 90: a(2) = 60: a(3) = 45: a(4) = 30: a(5) = 20: a(6) = 10
'choix de la difficulté
CALL Niveau(ni, 2)

SCREEN 9

MouseHide
FOR jj = 1 TO 10 '+++++
erreurs = 0

CALL titre2(titr$)
LINE (430, 44)-(620, 260), noir, BF
LINE (430, 44)-(620, 260), rouge, B

LOCATE 22, 77: COLOR vertclair: PRINT 11 - jj

IF jj < 6 THEN
IF ni = 1 THEN
GOSUB fractionniv1bis
ELSE
GOSUB fractionniv2bis
END IF
ELSE
IF ni = 1 THEN
GOSUB fractionniv1
ELSE
GOSUB fractionniv2
END IF
END IF

COLOR , noir
LOCATE 6, 63
PRINT "Fraction"
LOCATE , 60
PRINT "correspondant"
LOCATE , 59
PRINT "aux parts rouges"

fra1:
CALL cadre3(12, 65, 2, jaune)
LINE (490, 174)-(550, 176), blancbrill, BF
CALL cadre3(14, 65, 2, blancbrill)
CALL centre(23, blanc, "Tape la réponse")

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG
LOCATE 12, 65
CALL inputgen(2, r$, 48, 57, noir)
MouseHide
r = VAL(r$)
LOCATE 23, 1: PRINT SPACE$(80)
IF r = numerateur THEN
CALL exact2
IF erreurs = 0 THEN
re! = re! + 1
ELSEIF erreurs = 1 THEN
re! = re! + .5
END IF
ELSE
erreurs = erreurs + 1
IF erreurs = 1 THEN
IF ni = 1 THEN
CALL centre(23, rougeclair, "Tu dois compter les parts rouges.")
ELSE
CALL centre(23, rougeclair, "Tu dois compter toutes les parts rouges.")
END IF
ELSEIF erreurs > 1 THEN
CALL solution(STR$(numerateur))
END IF
CALL attendre(2)
LOCATE 23, 1: PRINT SPACE$(80)
GOTO fra1
END IF

CALL cadre3(12, 65, 2, blancbrill)
erreurs = 0
fra2:
CALL cadre3(14, 65, 2, jaune)
CALL centre(23, blanc, "Tape la réponse")

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG
LOCATE 14, 65
CALL inputgen(2, r$, 48, 57, noir)
r = VAL(r$)

LOCATE 23, 1: PRINT SPACE$(80)

IF r = denominateur THEN
CALL exact2
IF erreurs = 0 THEN
re! = re! + 1
ELSEIF erreurs = 1 THEN
re! = re! + .5
END IF
ELSE
erreurs = erreurs + 1
IF erreurs = 1 THEN
IF ni = 1 THEN
CALL centre(23, rougeclair, "Tu dois compter toutes les parts.")
ELSE
IF jj < 6 THEN
CALL centre(23, rougeclair, "Tu dois compter les parts d'un seul rectangle.")
ELSE
CALL centre(23, rougeclair, "Tu dois compter les parts d'un seul cercle.")
END IF
END IF
ELSE
CALL solution(STR$(denominateur))
END IF
CALL attendre(2)
LOCATE 23, 1: PRINT SPACE$(80)
GOTO fra2
END IF

NEXT jj '+++++++++++++++++++++++++++++++++++++++++++++

SCREEN 0
'résultats
re = INT(re! / 2)
CALL resultats(re, ni, 2)

EXIT SUB

fractionniv1:
'tirage de a(angle) 'angle 6 possibilités
DO
f = 0
z(jj) = INT(RND * 6) + 1
FOR j = 1 TO jj - 1
IF z(jj) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
angle = z(jj)

'tirage de la limite en fonction de l'angle
DO
f = 0
z2(jj) = INT(RND * (360 / a(angle))) + 1
FOR j = 1 TO jj - 1
IF z2(jj) = z2(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
limite = z2(jj) * a(angle)

numerateur = z2(jj)
denominateur = 360 / a(angle)

'dessin du cercle et des parts
CIRCLE (180, 150), 140, vert, , , coef2!
FOR d = 0 TO 360 STEP a(angle)
DRAW "TA=" + VARPTR$(d) + "NU102"
NEXT d
FOR d = 0 TO limite - 1 STEP a(angle)
an = d + 5
DRAW "TA=" + VARPTR$(an) + "bU50"
PAINT STEP(0, 0), rouge, vert
DRAW "BM180,150"
NEXT d
RETURN

fractionniv1bis:
'tirage
DO
f = 0
zz(jj) = INT(RND * 10) + 1
FOR j = 1 TO jj - 1
IF zz(jj) = zz(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1 OR zz(j) = 1

numerateur = zz(jj)
denominateur = 10

x = 100: y = 130
LINE (x, y)-(x + 200, y + 40), vert, B
DRAW "BM=" + VARPTR$(x) + ",=" + VARPTR$(y)
FOR i = 1 TO 5
DRAW "d40r20u40r20"
NEXT
x = x + 5: y = y + 5
FOR i = 1 TO numerateur
PAINT (x, y), rouge, vert
x = x + 20
NEXT
RETURN

fractionniv2:
'au niveau 2 il y a deux cercles

'tirage de a(angle) 'angle 5 possibilités
DO
f = 0
z(jj) = INT(RND * 5) + 1
FOR j = 1 TO jj - 1
IF z(jj) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
angle = z(jj)

'tirage de la limite en fonction de l'angle
DO
f = 0
z2(jj) = INT(RND * (360 / a(angle))) + 1
FOR j = 1 TO jj - 1
IF z2(jj) = z2(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1

limite = z2(jj) * a(angle)

denominateur = 360 / a(angle)
numerateur = denominateur + z2(jj)

'dessin du 1° cercle et des parts
CIRCLE (100, 150), 80, vert, , , coef2!
PAINT (100, 150), rouge, vert
LINE (100, 150)-(100, 150), vert
FOR d = 0 TO 360 STEP a(angle)
DRAW "TA=" + VARPTR$(d) + "NU58"
NEXT d
'dessin du 2° cercle et des parts
CIRCLE (300, 150), 80, vert, , , coef2!
FOR d = 0 TO 360 STEP a(angle)
DRAW "TA=" + VARPTR$(d) + "NU58"
NEXT d
FOR d = 0 TO limite - 1 STEP a(angle)
an = d + 5
DRAW "TA=" + VARPTR$(an) + "bU30"
PAINT STEP(0, 0), rouge, vert
DRAW "BM300,150"
NEXT d
RETURN

fractionniv2bis:
'tirage
DO
f = 0
zz(jj) = INT(RND * 10) + 10
FOR j = 1 TO jj - 1
IF zz(jj) = zz(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1

numerateur = zz(jj)
denominateur = 10

x = 100: y = 80
LINE (x, y)-(x + 200, y + 40), vert, B
DRAW "BM=" + VARPTR$(x) + ",=" + VARPTR$(y)
FOR i = 1 TO 5
DRAW "d40r20u40r20"
NEXT
x = x + 5: y = y + 5
FOR i = 1 TO 10
PAINT (x, y), rouge, vert
x = x + 20
NEXT

x = 100: y = 170
LINE (x, y)-(x + 200, y + 40), vert, B
DRAW "BM=" + VARPTR$(x) + ",=" + VARPTR$(y)
FOR i = 1 TO 5
DRAW "d40r20u40r20"
NEXT

x = x + 5: y = y + 5
FOR i = 1 TO numerateur - 10
PAINT (x, y), rouge, vert
x = x + 20
NEXT

RETURN

END SUB

DEFDBL A-Z
SUB lettre (re%, ni%, un2$(), di2$(), ex2$(), ch$(), mot$(), rt$, gg$, nom$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'1/12/2001
DIM p(2), tr$(20), re$(120), z(10), nb(18), nb$(18), m$(50), m2$(50), m3$(50), m4$(50)

z$ = "0000000000"
l$ = STRING$(40, 196)
s$ = "xxxxxx"
ct% = 0

CALL Niveau(ni%, 3)

COLOR , bleu%: CLS
IF ni% = 1 THEN ti% = 1
IF ni% = 2 THEN ti% = 19
IF ni% = 3 THEN
CALL chiflet(re%, ni%, mot$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
EXIT SUB
END IF
MouseHide
COLOR jaune%: LOCATE 3, 3: PRINT "Rappel"
CALL cadre(4, 2, 75, 17, rouge%)

COLOR , rouge%
h% = 10
LOCATE 7, h%: COLOR jaune%: PRINT "Million"; : COLOR blancbrill%: PRINT " s'accorde comme un nom."
LOCATE 9, h%: COLOR jaune%: PRINT "Vingt"; : COLOR blancbrill%: PRINT " et "; : COLOR jaune%: PRINT "cent"; : COLOR blancbrill%: PRINT " s'accordent s'ils sont à la fin du nombre."

CALL place(11, h%, "Les autres mots sont invariables.", jaune%)
h% = 25
CALL place(14, h%, "Exemples :", vertclair%)
LOCATE 16, h%: PRINT "- quatre million"; : COLOR jaune%: PRINT "s"; : COLOR vertclair%
PRINT " deux cent"; : COLOR jaune%: PRINT "s"
COLOR vertclair%
LOCATE 18, h%: PRINT "- deux cent quatre-vingt"; : COLOR jaune%: PRINT "s"
CALL entree(bleu%, bleu%)

j% = 1
FOR i% = ti% TO ti% + 17
nb(j%) = VAL(ch$(i%))
nb$(j%) = ch$(i%)
j% = j% + 1
NEXT


FOR ii% = 1 TO 5 '++++++++++++++++++++++++++++++++++++++++++++++
COLOR , noir%: CLS
COLOR , vert%
LOCATE 2, 1: PRINT SPACE$(80)
CALL centre(2, noir%, UCASE$(titr$))
LOCATE 20, 1: PRINT SPACE$(80)
VIEW PRINT 3 TO 19: COLOR blancbrill%, bleu%: CLS 2: VIEW PRINT
COLOR noir%, vert%
LOCATE 20, 2: PRINT " Niveau"; ni%
LOCATE 20, 77
PRINT 6 - ii%

GOSUB letcheque

c% = 0
'tirage
DO
f% = 0
z(ii%) = INT(RND * 18) + 1
FOR j% = 1 TO ii% - 1
IF z(ii%) = z(j%) THEN f% = 1: EXIT FOR
NEXT
LOOP WHILE f% = 1
n = nb(z(ii%))
nb$ = nb$(z(ii%))

'transforme
n$ = LTRIM$(STR$(n)): n$ = LEFT$(z$, 10 - LEN(n$)) + n$: n2$ = ""
i% = 0: FOR j% = 1 TO 7 STEP 3
tr$(i%) = MID$(n$, 9 - j%, 3)
i% = i% + 1
NEXT
'unités simples
f% = 0: tr$ = tr$(0): IF VAL(tr$) = 0 THEN GOTO let4
GOSUB letanalyse
n2$ = no$
'mille
let4:
f% = 1: tr$ = tr$(1): IF VAL(tr$) = 0 THEN GOTO let5
IF VAL(tr$) = 1 THEN n2$ = "mille " + n2$: GOTO let5
GOSUB letanalyse
n2$ = no$ + "mille " + n2$
'million
let5:
tr$ = tr$(2): IF VAL(tr$) = 0 THEN GOTO let6
IF VAL(tr$) = 1 THEN n2$ = "un million " + n2$: GOTO let6
GOSUB letanalyse
n2$ = no$ + "millions " + n2$
let6:
n2$ = MID$(n2$, 1, LEN(n2$) - 1)

COLOR , noir%
CALL centre(22, blanc%, "Tape le nombre en lettres")
r$ = ""
LOCATE 6, 59
COLOR noir%, blanc%
PRINT nb$; " "

let8:
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &HBF)'minus
DEF SEG
COLOR noir%, blanc%
LOCATE 9, 30: PRINT STRING$(47, ".")
LOCATE 9, 30, 1
CALL inputgen(47, r$, 32, 254, blanc%)

b$ = LCASE$(r$): IF b$ = CHR$(13) OR LEN(b$) < 2 THEN GOTO let8
lo% = LEN(b$)

'analyse-
'enlève les guillemets
FOR ik% = 1 TO LEN(b$)
IF MID$(b$, ik%, 1) = "-" THEN
b$ = MID$(b$, 1, ik% - 1) + " " + MID$(b$, ik% + 1)
END IF
NEXT
'enlève les espaces
ik% = 1
DO
IF ASC(MID$(b$, ik%, 1)) = 32 THEN
IF ASC(MID$(b$, ik% + 1, 1)) = 32 THEN
b$ = MID$(b$, 1, ik%) + MID$(b$, ik% + 2): lo% = lo% - 1: ik% = ik% - 1
END IF
END IF
ik% = ik% + 1
LOOP WHILE ik% <> lo%

IF ASC(b$) < 65 THEN
CALL chiffreslettres(noir%, noir%, 2)
GOTO let8
END IF

IF RIGHT$(b$, 2) = " f" THEN b$ = MID$(b$, 1, LEN(b$) - 2)
IF RIGHT$(b$, 3) = " f." THEN b$ = MID$(b$, 1, LEN(b$) - 3)
IF RIGHT$(b$, 7) = " francs" THEN b$ = MID$(b$, 1, LEN(b$) - 7)
IF RIGHT$(b$, 6) = " franc" THEN b$ = MID$(b$, 1, LEN(b$) - 6)
IF RIGHT$(b$, 2) = " e" THEN b$ = MID$(b$, 1, LEN(b$) - 2)
IF RIGHT$(b$, 5) = " euro" THEN b$ = MID$(b$, 1, LEN(b$) - 5)
IF RIGHT$(b$, 6) = " euros" THEN b$ = MID$(b$, 1, LEN(b$) - 6)

COLOR blancbrill%, noir%
LOCATE 21, 1: PRINT SPACE$(80): PRINT SPACE$(80): PRINT SPACE$(80)
LOCATE 22, 3

IF b$ <> n2$ THEN
BEEP
IF c% = 0 THEN ct% = ct% + 1
c% = c% + 1

IF c% > 2 THEN
BEEP
CALL centre(22, rougeclair%, "Solution : " + LTRIM$(n2$))
ELSE
COLOR jaune%
LOCATE 21, 3: PRINT "Ta réponse : "; : COLOR blancbrill%: PRINT r$
COLOR rougeclair%
CALL trouvemot(b$, m$(), nm%): b$ = MID$(b$, 1, LEN(b$) - 1)
CALL trouvemot(n2$, m2$(), nm2%): n2$ = MID$(n2$, 1, LEN(n2$) - 1)
LOCATE 22, 3
IF nm% < nm2% THEN PRINT "Il manque des mots..."
IF nm% > nm2% THEN PRINT "Il y a trop de mots..."
z% = 0
FOR j% = 1 TO nm%
f% = 0
FOR i% = 1 TO 33
IF mot$(i%) = m$(j%) THEN f% = 1: EXIT FOR
NEXT i%
IF f% = 0 THEN z% = z% + 1: m3$(z%) = m$(j%)
NEXT j%
LOCATE 23, 3
COLOR jaune%

IF z% = 0 THEN
z2% = 0
FOR i% = 1 TO nm2%
IF m2$(i%) <> m$(i%) THEN z2% = z2% + 1: m4$(z2%) = m2$(i%)
NEXT
f% = 0
FOR i% = 1 TO nm%
IF m$(i%) = "zéro" OR m$(i%) = "zero" THEN f% = 1
NEXT
IF f% = 1 THEN COLOR rougeclair%: PRINT "Pas de zéro...": z2% = 0
IF z2% <> 0 THEN PRINT "Aide : "; : COLOR rougeclair%: FOR i% = 1 TO z2%: PRINT m4$(i%); ", "; : NEXT: PRINT CHR$(29); CHR$(29); " "
ELSEIF z% = 1 THEN
PRINT "Mot mal orthographié : "; : COLOR rougeclair%: PRINT m3$(1)
ELSE
temp$ = "": FOR i% = 1 TO z%: temp$ = temp$ + m3$(i%) + ", ": NEXT
IF LEN(temp$) < 55 THEN
PRINT "Mots mal orthographiés : "; : COLOR rougeclair%
FOR i% = 1 TO z%: PRINT m3$(i%); ", "; : NEXT: PRINT CHR$(29); CHR$(29); " "
END IF
END IF

END IF
GOTO let8

END IF


LOCATE 21, 1: PRINT SPACE$(80): PRINT SPACE$(80)
CALL centre(22, jaune%, "Exact")
CALL attendre(1.5)
CALL centre(22, 15, SPACE$(6))

NEXT ii% '+++++++++++++++++++++++++++++++++++++++++++++++++++++

'Résultats
re% = 10 - (ct% * 2): IF re% < 0 THEN re% = 0
CALL resultats(re%, ni%, 3)

EXIT SUB


letanalyse:
no$ = ""
FOR i% = 2 TO 0 STEP -1
p(i%) = VAL(MID$(tr$, 3 - i%, 1))
NEXT
'centaine
IF p(2) = 0 THEN GOTO let1
IF p(2) = 1 THEN no$ = "cent ": GOTO let1
no$ = un2$(p(2)) + "cent"
IF p(0) <> 0 OR p(1) <> 0 THEN GOTO let2
IF f% = 0 THEN no$ = no$ + "s"
let2:
no$ = no$ + " "
let1: 'dizaine
IF p(1) = 0 THEN GOTO let3
IF p(1) = 7 AND p(0) = 1 THEN no$ = no$ + di2$(p(1) - 1) + "et " + ex2$(p(0)): RETURN
IF p(1) = 1 AND (p(0) > 0 AND p(0) < 7) THEN no$ = no$ + ex2$(p(0)): RETURN
IF (p(1) = 7 OR p(1) = 9) AND (p(0) > 0 AND p(0) < 7) THEN no$ = no$ + di2$(p(1) - 1) + ex2$(p(0)): RETURN
IF p(0) = 1 AND (p(1) <> 0 AND p(1) <> 8) THEN no$ = no$ + di2$(p(1)) + "et ": GOTO let3
no$ = no$ + di2$(p(1))
IF f% = 0 AND (p(1) = 8 AND p(0) = 0) THEN no$ = LEFT$(no$, LEN(no$) - 1) + "s "
let3: 'unités
IF p(0) = 0 THEN RETURN
no$ = no$ + un2$(p(0))
RETURN

letcheque:
LOCATE , , 0
CALL cadre(4, 2, 75, 14, blanc%)
COLOR marron%, blanc%

LOCATE 13, 5: PRINT "┌"; STRING$(26, 196); "┐"
FOR i% = 1 TO 3: LOCATE , 5: PRINT "│"; : LOCATE , 5 + 27: PRINT "│": NEXT
LOCATE , 5: PRINT "└"; STRING$(26, 196); "┘"

CALL cadrenb(5, 5, 22, 2, noir%, noir%, rouge%)
LOCATE 6, 7: COLOR blancbrill%: PRINT "$ BANQUE PIQUESOUS $"
COLOR noir%, blanc%
LOCATE 6, 50: PRINT "EUROS : "
LOCATE 9, 5: PRINT "PAYEZ CONTRE CE CHEQUE :"
LOCATE 11, 5: PRINT "A Monsieur CLERC"
LOCATE 13, 5
PRINT "PAYABLE A"
LOCATE 14, 7
PRINT "91700 Ste. Geneviève": LOCATE , 7: PRINT "Place du Donjon": LOCATE , 7: PRINT "Compensable à EVRY"

LOCATE 13, 40: PRINT "A Sainte Geneviève le"
'date
da$ = MID$(DATE$, 4, 2) + "/" + MID$(DATE$, 1, 2) + "/" + MID$(DATE$, 7)
IF LEFT$(da$, 1) = "0" THEN da$ = MID$(da$, 2)
LOCATE 13, 62: PRINT da$
LOCATE 15, 40: PRINT "Monsieur ou Mademoiselle"
LOCATE , 40: IF pre$ <> "" THEN PRINT pre$; " "; nom$ ELSE PRINT "Jean DUPONT"
RETURN

END SUB

DEFINT A-Z
SUB memoire (re, ni, rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'16/3/95
DIM a(4), b(4)
re = 0

w$ = "Quatre nombres vont être affichés"
z$ = "Tu devras les retaper."
CALL consigne(2, w$, z$, y$)

CALL Niveau(ni, 2)
IF ni = 1 THEN c! = .65: d = 30
IF ni = 2 THEN c! = .6: d = 90

CALL titre

FOR kk = 1 TO 5 '+++++++++++++++++++
MouseHide
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

coul = rouge: GOSUB me10: CALL ligne23(noir, bleu, 0)
CALL niv(5, kk)
COLOR , noir
CALL centre(23, blanc, "Lis les nombres"): COLOR blancbrill
CALL attendre(c!)

FOR n = 0 TO 3
LOCATE 12: h = n * 9 + 25
LOCATE , h
DO
a(n) = INT(RND * d)
LOOP WHILE a(n) < 10
COLOR blancbrill, rouge: PRINT a(n)
CALL attendre(c!)
NEXT n
CALL attendre(c!)
coul = blanc: GOSUB me10
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

FOR i = 0 TO 3
LOCATE 23, 32: COLOR blanc, noir: PRINT "Tape le nombre n°"; : COLOR blancbrill: PRINT LTRIM$(STR$(i + 1))
h = i * 9 + 26
COLOR , blanc
LOCATE 12, h: CALL inputgen(2, r$, 48, 57, blanc): b(i) = VAL(r$)
NEXT
CALL ligne23(noir, noir, 0)
IF a(0) = b(0) AND a(1) = b(1) AND a(2) = b(2) AND a(3) = b(3) THEN
re = re + 2
CALL exact2
ELSE
CALL centre(23, rougeclair, "Solution :" + STR$(a(0)) + "," + STR$(a(1)) + "," + STR$(a(2)) + "," + STR$(a(3)))
IF a(0) = b(0) AND a(1) = b(1) AND a(2) = b(2) THEN
re = re + 1
ELSEIF a(0) = b(0) AND a(1) = b(1) AND a(3) = b(3) THEN
re = re + 1
ELSEIF a(1) = b(1) AND a(2) = b(2) AND a(3) = b(3) THEN
re = re + 1
ELSEIF a(0) = b(0) AND a(1) = b(1) AND a(3) = b(3) THEN
re = re + 1
ELSEIF a(0) = b(0) AND a(2) = b(2) AND a(3) = b(3) THEN
re = re + 1
END IF
CALL getinvimouse(w)
END IF
NEXT kk '++++++++++++++++++++++

CALL resultats(re, ni, 2)
EXIT SUB

me10:
CALL cadre(10, 24, 4, 4, coul)
CALL cadre(10, 33, 4, 4, coul)
CALL cadre(10, 42, 4, 4, coul)
CALL cadre(10, 51, 4, 4, coul)
RETURN

END SUB

DEFINT A-Z
SUB multiples (re, ni, rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'11/4/96
'ne sert que si le programme ne peut afficher en graphique
DIM n(6), n$(6)
c = 0

CALL titre
w$ = "Un tableau contenant des nombres va être affiché."
IF pre$ <> "" THEN
CALL centre(7, blancbrill, pre$ + ","): w$ = LCASE$(w$)
END IF
CALL centre(9, blancbrill, w$)
CALL centre(12, blancbrill, "A chaque fois qu'un nombre sera multiple de 1, 2, 3, 5, 6, 9 ou 10,")
LOCATE 14, 18: PRINT "il faudra que tu appuies sur touche "; : COLOR jaune: PRINT "O"; : COLOR blancbrill: PRINT " (Oui).": PRINT
LOCATE 17, 11: PRINT "Dans le cas contraire, tu appuieras sur la touche "; : COLOR jaune: PRINT "N"; : COLOR blancbrill: PRINT " (Non)."
CALL entree(noir, noir)
CLS
LOCATE 2, 3: COLOR jaune: PRINT "Rappel": COLOR blancbrill
CALL cadre(4, 2, 76, 16, rouge)
LOCATE 6, 5: COLOR , bleu
PRINT "- Tous les nombres sont multiples de "; : COLOR jaune: PRINT "1"; : COLOR blancbrill: PRINT "."
PRINT : LOCATE , 5: PRINT "- Les nombres pairs sont multiples de "; : COLOR jaune: PRINT "2"; : COLOR blancbrill: PRINT "."
PRINT : LOCATE , 5: PRINT "- La somme des chiffres des multiples de "; : COLOR jaune: PRINT "3"; : COLOR blancbrill: PRINT " est égale à 3, 6 ou 9."
PRINT : LOCATE , 5: PRINT "- Les multiples de "; : COLOR jaune: PRINT "5"; : COLOR blancbrill: PRINT " se terminent par 0 ou 5."
PRINT : LOCATE , 5: PRINT "- Les multiples de "; : COLOR jaune: PRINT "6"; : COLOR blancbrill: PRINT " sont multiples de 2 et de 3."
PRINT : LOCATE , 5: PRINT "- La somme des chiffres des multiples de "; : COLOR jaune: PRINT "9"; : COLOR blancbrill: PRINT " est égale à 9."
PRINT : LOCATE , 5: PRINT "- Les multiples de "; : COLOR jaune: PRINT "10"; : COLOR blancbrill: PRINT " se terminent par 0."
CALL entree(noir, noir)

CALL Niveau(ni, 2)
ni = ni + 1

'TABLEAU
'L1$= " ════════╬═══╪═══╪═══╪═══╪═══╪═══╪═══╡"
l2$ = " ────────┼───┼───┼───┼───┼───┼───┼───┤"
l3$ = " │ │ │ │ │ │ │ │"
l4$ = " ────────┴───┴───┴───┴───┴───┴───┴───┘"
CALL titre
v = 5: LOCATE v
COLOR jaune: LOCATE v, 32: PRINT "1 2 3 5 6 9 10": COLOR blanc
LOCATE v, 30: PRINT "│"
h = 34: FOR i = 1 TO 7: LOCATE v, h: PRINT "│": h = h + 4: NEXT
h = 21
LOCATE , h: PRINT l2$
FOR i = 1 TO 5: LOCATE , h: PRINT l3$: LOCATE , h: PRINT l2$: NEXT
LOCATE , h: PRINT l3$: LOCATE , h: PRINT l4$
COLOR blancbrill

'TIRAGE
FOR i = 1 TO 6
DO
n(i) = INT(RND * 10 ^ ni) + 1
LOOP WHILE n(i) < 10
n$(i) = LTRIM$(STR$(n(i)))
NEXT
' AFFICHAGE NOMBRES
v = 7: COLOR jaune
FOR i = 1 TO 6
LOCATE v, 28 - LEN(n$(i))
PRINT n$(i)
v = v + 2
NEXT
COLOR blancbrill

GOSUB mu12

'CURSEUR
h = 32: v = 7: f = 1
FOR i = 1 TO 6
FOR j = 1 TO 7
GOSUB muouinon
h = h + 4
NEXT j
h = 32: v = v + 2: f = f + 1
NEXT i
COLOR , noir: LOCATE 23: PRINT SPACE$(80)
LOCATE 23, 32
IF c > 1 THEN COLOR rougeclair: PRINT "Tu as fait"; c; "erreurs."
CALL getinvimouse(w)
re = 10 - c: IF re < 0 THEN re = 0

ni = ni - 1 'voir en haut
CALL resultats(re, ni, 2)

EXIT SUB

muouinon:
mu0:
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

LOCATE v, h, 1: r$ = UCASE$(INPUT$(1)): LOCATE , , 0
IF ASC(r$) = 27 THEN CALL quitter(noir, bleu): GOSUB mu12: GOTO mu0
IF r$ <> "O" AND r$ <> "N" THEN BEEP: GOTO mu0
COLOR vertclair: PRINT r$: COLOR blancbrill
MU = 1
IF j = 2 THEN MU = 2
IF j = 3 THEN MU = 3
IF j = 4 THEN MU = 5
IF j = 5 THEN MU = 6
IF j = 6 THEN MU = 9
IF j = 7 THEN MU = 10
IF n(f) / MU = INT(n(f) / MU) THEN IF r$ = "N" THEN re$ = "O": GOSUB mucorrect
IF n(f) / MU <> INT(n(f) / MU) THEN IF r$ = "O" THEN re$ = "N": GOSUB mucorrect
RETURN
mucorrect:
BEEP: CALL attendre(.2): LOCATE v, h: COLOR rougeclair: PRINT re$: COLOR blancbrill: c = c + 1
RETURN

mu12:
COLOR blanc, noir: LOCATE 23, 27: PRINT "Réponds par "; : COLOR jaune: PRINT "O"; : COLOR blanc: PRINT "ui ou par "; : COLOR jaune: PRINT "N"; : COLOR blanc: PRINT "on": COLOR blancbrill, bleu
RETURN
END SUB

DEFINT A-Z
SUB orth (re, ni, mo$(), mo2$(), mo3$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
DIM p2$(5), z(20), p$(2), s$(20), s2$(20)
'10/4/96

p2$(1) = "très lente": p2$(2) = "lente": p2$(3) = "moyenne"
p2$(4) = "rapide": p2$(5) = "très rapide"
lp$ = STRING$(22, ".")

c = 0: re = 0

'niveau
p$(1) = "Les nombres": p$(2) = "Les mots"
CALL titre
CALL cadre(7, 25, 30, 2, vert)
COLOR , vert
CALL centre(8, blancbrill, "Niveau de difficulté")
CALL fleches(13, 35, p$(), 2, ni, rouge, 1, 23, 35)

SELECT CASE ni
CASE 1
dernier = 10
CASE 2
dernier = 20
END SELECT

CALL titre

'tirage des mots
FOR ii = 1 TO 20
DO
f = 0
z(ii) = INT(RND * 20) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
nn = z(ii)

IF ni = 1 THEN
s$(ii) = mo$(nn): s2$(ii) = mo3$(nn)
ELSE
s$(ii) = mo2$(nn)
END IF
NEXT ii

'affichage des mots
CALL cadre(6, 22, 36, 11, marron)
COLOR blancbrill, marron
LOCATE 7
FOR i = 1 TO 10
LOCATE , 24
IF ni = 1 THEN PRINT mo$(i) ELSE PRINT mo2$(i)
NEXT
LOCATE 7
FOR i = 11 TO 20
LOCATE , 48
IF ni = 1 THEN PRINT mo$(i) ELSE PRINT mo2$(i)
NEXT

COLOR , noir
CALL centre(23, blanc, "Mémorise l'orthographe des mots")
CALL getinvimouse(r)

vi = 3

GOSUB orthexo1
IF ni = 1 THEN GOSUB orthexo2

re = INT(re / 2)
CALL resultats(re, ni, 2)

EXIT SUB

orthexo1:
FOR ii = 1 TO dernier '++++++++++
CALL titre
CALL cadre(10, 28, 24, 4, blanc)
MouseHide
erreurs = 0
CALL niv(20, ii)

DO
CALL cadre(6, 28, 24, 2, vert)
COLOR , vert
CALL centre(7, blancbrill, "Vitesse " + p2$(vi))
CALL attendre(.5)
COLOR , blanc

IF erreurs = 0 THEN
SELECT CASE ii
CASE 1, 4, 7, 10, 13, 16, 19
CALL centre(12, noir, s$(ii))
CALL attendre(2 / vi)

CASE 2, 5, 8, 11, 14, 17, 20
'lettre par lettre
CALL centre(12, noir, MID$(lp$, 1, LEN(s$(ii))))
COLOR noir, blanc
h = INT(41 - LEN(s$(ii)) / 2)
FOR x = 1 TO LEN(s$(ii))
LOCATE 12, h
PRINT MID$(s$(ii), x, 1)
CALL attendre(1 / vi)
LOCATE 12, h
PRINT "."
h = h + 1
NEXT

CASE 3, 6, 9, 12, 15, 18
'flash
FOR x = 1 TO 3
CALL centre(12, noir, s$(ii))
CALL attendre(.09)
CALL centre(12, noir, SPACE$(LEN(s$(ii))))
CALL attendre(.15)
NEXT
END SELECT

ELSE
CALL centre(12, noir, s$(ii))
CALL attendre(2 / vi)

END IF

h = INT(41 - LEN(s$(ii)) / 2)
CALL centre(12, noir, MID$(lp$, 1, LEN(s$(ii))))
COLOR , noir
CALL centre(23, blanc, "Tape la réponse")

nl = LEN(s$(ii))
LOCATE 12, h
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &HBF)'minus
DEF SEG
CALL inputgen(nl, r$, 65, 165, blanc)
r$ = LCASE$(r$)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF r$ = s$(ii) THEN
flag = flag + 1: CALL exact2
IF erreurs = 0 THEN re = re + 1
EXIT DO
ELSE
CALL erreur2
flag = 0: c = c + 1: erreurs = 1
IF c = 2 THEN c = 0: vi = vi - 1: IF vi < 1 THEN vi = 1
'_________________
'mettre en rouge là où c'est faux
COLOR , blanc
LOCATE 12, INT(41 - (LEN(s$(ii)) / 2))
FOR i = 1 TO LEN(r$)
IF MID$(s$(ii), i, 1) = MID$(r$, i, 1) THEN
COLOR noir
ELSE
COLOR rouge
END IF
PRINT MID$(r$, i, 1);
NEXT
PRINT
LOCATE 13, INT(41 - (LEN(s$(ii)) / 2))
'on compte les erreurs
flag2 = 0
FOR i = 1 TO LEN(r$)
IF MID$(s$(ii), i, 1) <> MID$(r$, i, 1) THEN
flag2 = flag2 + 1
END IF
NEXT

IF flag2 < 3 THEN
FOR i = 1 TO LEN(r$)
IF MID$(s$(ii), i, 1) = MID$(r$, i, 1) THEN
PRINT " ";
ELSE
COLOR rouge
PRINT CHR$(24);
END IF
NEXT
ELSE
CALL centre(13, noir, SPACE$(LEN(s$(ii))))
END IF
CALL attendre(1)
'________________

CALL ligne23(noir, noir, 0)
END IF

LOOP

IF vi = 1 AND flag = 2 THEN vi = 2: flag = 0
IF vi = 2 AND flag = 2 THEN vi = 3: flag = 0
IF vi = 3 AND flag = 3 THEN vi = 4: flag = 0
IF vi = 4 AND flag = 3 THEN vi = 5: flag = 0

NEXT ii '++++++++++++++

RETURN

orthexo2:

w$ = "maintenant, les nombres vont être indiqués"
z$ = "en chiffres."
CALL consigne(2, w$, z$, y$)

cc = 0
FOR ii = 11 TO 20 '++++++++++
CALL titre
CALL cadre(10, 28, 24, 4, blanc)

CALL niv(20, ii)

DO
COLOR , blanc
h = INT(41 - LEN(s$(ii)) / 2)
CALL centre(12, noir, MID$(lp$, 1, LEN(s$(ii))))

COLOR blanc, noir
LOCATE 23, INT(41 - (13 + LEN(s2$(ii)) / 2))
PRINT "Tape le nombre "; : COLOR jaune: PRINT s2$(ii); : COLOR blanc: PRINT " en lettres"

LOCATE 12, h
nl = LEN(s$(ii))
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &HBF)'minus
DEF SEG
CALL inputgen(nl, r$, 65, 165, blanc)
r$ = LCASE$(r$)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF r$ = s$(ii) THEN
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
ELSE
cc = cc + 1

CALL erreur2
IF cc > 2 THEN
COLOR , blanc
CALL centre(12, noir, s$(ii))
CALL attendre(1)
ELSE
'_________________
'mettre en rouge là où c'est faux
COLOR , blanc
LOCATE 12, INT(41 - (LEN(s$(ii)) / 2))
FOR i = 1 TO LEN(r$)
IF MID$(s$(ii), i, 1) = MID$(r$, i, 1) THEN
COLOR noir
ELSE
COLOR rouge
END IF
PRINT MID$(r$, i, 1);
NEXT
PRINT
LOCATE 13, INT(41 - (LEN(s$(ii)) / 2))
'on compte les erreurs
flag2 = 0
FOR i = 1 TO LEN(r$)
IF MID$(s$(ii), i, 1) <> MID$(r$, i, 1) THEN
flag2 = flag2 + 1
END IF
NEXT

IF flag2 < 3 THEN
FOR i = 1 TO LEN(r$)
IF MID$(s$(ii), i, 1) = MID$(r$, i, 1) THEN
PRINT " ";
ELSE
COLOR rouge
PRINT CHR$(24);
END IF
NEXT
ELSE
CALL centre(13, noir, SPACE$(LEN(s$(ii))))
END IF
CALL attendre(1)
'________________

CALL ligne23(noir, noir, 0)
END IF
END IF

LOOP

NEXT ii '++++++++++++++

RETURN

END SUB

DEFINT A-Z
SUB romains (re, ni, UR$(), DR$(), CR$(), MR$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'10/4/96
DIM p$(6)
re = 0

'rappel
COLOR jaune, bleu: CLS
LOCATE 2, 23: PRINT "RAPPEL"
CALL cadre(3, 22, 36, 18, rouge)
COLOR , rouge
LOCATE 5, 25: COLOR jaune: PRINT "I"; : COLOR blancbrill: PRINT " = 1"
LOCATE 7, 25: COLOR jaune: PRINT "V"; : COLOR blancbrill: PRINT " = 5"
LOCATE 9, 25: COLOR jaune: PRINT "X"; : COLOR blancbrill: PRINT " = 10"
LOCATE 11, 25: COLOR jaune: PRINT "L"; : COLOR blancbrill: PRINT " = 50"
LOCATE 13, 25: COLOR jaune: PRINT "C"; : COLOR blancbrill: PRINT " = 100"
LOCATE 15, 25: COLOR jaune: PRINT "D"; : COLOR blancbrill: PRINT " = 500"
LOCATE 17, 25: COLOR jaune: PRINT "M"; : COLOR blancbrill: PRINT " = 1000"
LOCATE 5
FOR i = 1 TO 9: LOCATE , 44: PRINT i; "= "; UR$(i): NEXT
LOCATE 14, 44: PRINT "10 = X": LOCATE 15, 44: PRINT "11 = XI"
LOCATE 16, 44: PRINT "12 = XII": LOCATE 17, 44: PRINT "13 = XIII"
CALL centre(19, vertclair, "Jamais 4 signes identiques !")
CALL entree(bleu, bleu)

'niveau
CALL Niveau(ni, 3)
IF ni = 1 THEN n2 = 100: nm = 1
IF ni = 2 THEN n2 = 800: nm = 101
IF ni = 3 THEN n2 = 3999: nm = 801

'romains -> arabes avec plusieurs choix

FOR ij = 1 TO 4 '+++++++++
CALL titre
CALL niv(12, ij)

GOSUB rotirage
sol = no
bon = INT(RND * 5) + 1
p$(bon) = LTRIM$(STR$(sol))
plus = sol + INT(RND * sol / 3): IF plus = sol THEN plus = plus + 1
plus2 = sol + INT(RND * sol / 4): IF plus2 = sol THEN plus2 = plus2 + 1
IF plus = plus2 THEN plus = plus + 1
moins = sol - INT(RND * sol / 3): IF moins = sol THEN moins = moins - 1
moins2 = sol - INT(RND * sol / 4): IF moins2 = sol THEN moins2 = moins2 - 1
IF moins = moins2 THEN moins = moins - 1
IF moins < 0 THEN moins = 0
plus3 = plus2 + 2

IF bon = 1 THEN
p$(2) = LTRIM$(STR$(plus))
p$(3) = LTRIM$(STR$(moins))
p$(4) = LTRIM$(STR$(plus2))
p$(5) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

ELSEIF bon = 2 THEN
p$(1) = LTRIM$(STR$(moins))
p$(4) = LTRIM$(STR$(plus))
p$(3) = LTRIM$(STR$(plus2))
p$(5) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

ELSEIF bon = 3 THEN
p$(5) = LTRIM$(STR$(moins))
p$(4) = LTRIM$(STR$(plus))
p$(2) = LTRIM$(STR$(plus2))
p$(1) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

ELSEIF bon = 4 THEN
p$(5) = LTRIM$(STR$(moins))
p$(1) = LTRIM$(STR$(plus))
p$(3) = LTRIM$(STR$(plus2))
p$(2) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

ELSE
p$(2) = LTRIM$(STR$(moins))
p$(3) = LTRIM$(STR$(plus))
p$(1) = LTRIM$(STR$(plus2))
p$(4) = LTRIM$(STR$(moins2))
p$(6) = LTRIM$(STR$(plus3))

END IF



IF ni = 3 THEN
CALL cadre(7, 48, 6, 7, rouge)
CALL cadre(7, 24, 14, 2, marron)
CALL cadre(10, 24, 14, 4, blanc)
ELSE
CALL cadre(7, 48, 5, 7, rouge)
CALL cadre(7, 24, 12, 2, marron)
CALL cadre(10, 24, 12, 4, blanc)
END IF

COLOR blancbrill, marron
LOCATE 8, 26: PRINT "Romains"
LOCATE 12, 26: COLOR noir, blanc: PRINT nr$
COLOR , rouge

DO
CALL fleches(8, 50, p$(), 6, r, rouge, 0, 23, 46)
CALL ligne23(noir, noir, 0)

IF r = bon THEN
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
ELSE
cc = cc + 1
IF cc = 1 THEN
CALL erreur2
ELSE
BEEP
CALL centre(23, rougeclair, "Solution :" + STR$(sol))
CALL attendre(2)
CALL ligne23(noir, bleu, 0)
END IF
END IF
LOOP
NEXT ij '+++++++++ fin 1° série

'romains -> arabes
FOR ij = 5 TO 8 '+++++++++++++
CALL titre
MouseHide
IF ij = 5 THEN CALL attendre(.5)
CALL niv(12, ij)

GOSUB rotirage

CALL cadre(7, 24, 12, 2, marron)
COLOR blancbrill, marron
LOCATE 8, 26: PRINT "Romains"
CALL cadre(10, 24, 12, 4, rouge)
LOCATE 12, 26: COLOR blancbrill, rouge: PRINT nr$

CALL cadre(10, 45, 10, 4, blanc)

DO
COLOR , noir
IF cc < 2 THEN
CALL centre(23, blanc, "Tape la réponse")
END IF
COLOR blanc, blanc
LOCATE 12, 47: PRINT SPACE$(7)
COLOR noir, blanc
LOCATE 12, 47: PRINT "_"
LOCATE 12, 47
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &h30)'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG

CALL inputgen(7, r$, 48, 58, blanc)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF r$ = no$ THEN
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
ELSE
cc = cc + 1
IF cc = 1 THEN
CALL erreur2
ELSE
BEEP
CALL centre(23, rougeclair, "Solution : " + no$)
CALL attendre(2)
END IF
END IF
LOOP
NEXT ij '+++++++++++++++++++ fin 2° série

'arabes/romains
FOR ij = 9 TO 12 '++++++++
CALL titre
IF ij = 9 THEN CALL attendre(.5)

CALL niv(12, ij)

GOSUB rotirage

CALL cadre(10, 25, 6, 4, rouge)
LOCATE 12, 27: COLOR blancbrill, rouge: PRINT no$


CALL cadre(7, 45, 16, 2, marron)
COLOR blancbrill, marron
LOCATE 8, 47: PRINT "Romains"
CALL cadre(10, 45, 16, 4, blanc)

DO
DO
IF cc < 2 THEN
COLOR , noir
CALL centre(23, blanc, "Tape la réponse")
END IF
COLOR blanc, blanc
LOCATE 12, 47: PRINT SPACE$(14)
COLOR noir, blanc
LOCATE 12, 47: PRINT "_"
LOCATE 12, 47
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &h30)'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG

CALL inputgen(14, r$, 65, 122, blanc)
r$ = UCASE$(r$)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF ASC(r$) < 67 OR ASC(r$) > 88 THEN
BEEP
CALL centre(23, rougeclair, "Des chiffres romains !")
CALL attendre(1)
LOCATE 23, 1: PRINT SPACE$(80)
END IF
LOOP WHILE ASC(r$) < 67 OR ASC(r$) > 88

IF r$ = nr$ THEN
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
ELSE
cc = cc + 1
IF cc = 1 THEN
CALL erreur2
ELSE
BEEP
CALL centre(23, rougeclair, "Solution : " + nr$)
CALL attendre(2)
END IF
END IF
LOOP
NEXT ij '+++++++++++++++++++ fin 3° série

re = re - 2: IF re < 0 THEN re = 0
CALL resultats(re, ni, 3)

EXIT SUB

rotirage:
DO
DO
HA = INT(RND * n2) + 1
LOOP WHILE HA = no
no = HA
LOOP WHILE no < nm

no$ = STR$(no): no$ = LTRIM$(no$)
'transf
m = 0: c = 0: d = 0: U = 0
l = LEN(no$)
U = VAL(MID$(no$, l, 1))
IF l = 1 THEN GOTO rotirage1
d = VAL(MID$(no$, l - 1, 1))
IF l = 2 THEN GOTO rotirage1
c = VAL(MID$(no$, l - 2, 1))
IF l = 3 THEN GOTO rotirage1
m = VAL(MID$(no$, l - 3, 1))
rotirage1:
nr$ = MR$(m) + CR$(c) + DR$(d) + UR$(U)
RETURN

END SUB

DEFINT A-Z
SUB soustractions (re%, ni%, flagscreen, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'10/3/95
DIM p$(2)
ll$ = STRING$(10, 196)

princsousti:
cc = 0: re = 0
CALL Niveau(ni, 3)
SELECT CASE ni
CASE 1, 2
IF ni = 1 THEN
n1 = 3: n2 = 2
ELSE
n1 = 3: n2 = 3
END IF
IF flagscreen = 0 THEN
p$(1) = "Retenues affichées": p$(2) = "Retenues non affichées"
CALL titre
CALL fleches(11, 32, p$(), 2, r, rouge, 1, 23, 35)
IF r = 1 THEN
CALL soustraction2(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
EXIT SUB
END IF
END IF

CASE 3
CALL soustdecimal(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
EXIT SUB
END SELECT

FOR no = 1 TO 5 '++++++++++++++
CALL titre
MouseHide
IF no = 1 THEN
CALL centre(12, jaune, "Le programme te signale les retenues.")
CALL attendre(2)
LOCATE 12: PRINT SPACE$(80)
END IF

CALL niv(5, no)

'tirage
sousi0:
DO
a& = INT(RND * (10 ^ n1))
a$ = LTRIM$(STR$(a&))
LOOP WHILE LEN(a$) <> n1
DO
b& = INT(RND * (10 ^ n2))
b$ = LTRIM$(STR$(b&))
LOOP WHILE LEN(b$) <> n2
IF a& < b& THEN GOTO sousi0

CALL cadre(8, 25, 30, 8, rouge)
COLOR , rouge
CALL soust(reponse$, a&, b&, cc%, 10, 41, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, rouge)

'resultats
LOCATE 23: COLOR , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
LOCATE 23, 32
COLOR rougeclair
PRINT "Tu as fait"; cc; "faute"; : IF cc > 1 THEN PRINT "s";
PRINT "."

IF cc > 4 AND ni > 1 AND no <> 5 THEN
CALL attendre(.7)
BEEP: CALL centre(23, rougeclair, "Tu vas changer de niveau.")
CALL getinvimouse(w)
f = 1: EXIT FOR
END IF
END IF
CALL getinvimouse(w)
cc = 0
NEXT no

IF f = 1 THEN GOTO princsousti

CALL resultats(re, ni, 3)

END SUB

DEFINT A-Z
SUB trouvemot (m$, m$(), nm)
jl = 1: MM$ = "": m$ = m$ + " "
FOR il = 1 TO LEN(m$)
MM$ = MM$ + MID$(m$, il, 1)
IF ASC(MID$(m$, il, 1)) = 32 THEN m$(jl) = MID$(MM$, 1, LEN(MM$) - 1): MM$ = "": jl = jl + 1: IF LEN(m$(jl - 1)) = 0 THEN jl = jl - 1
NEXT
nm = jl - 1

END SUB
 

 

DECLARE SUB niv (limit%, xx%)
DECLARE SUB attendre (tx!)
DECLARE SUB centre (v%, coul%, ph$)
DECLARE SUB chiffreslettres (x%, y%, t%)
DECLARE SUB convertir (z$)
DECLARE SUB convertir2 (no$)
DECLARE SUB entree (y%, z%)
DECLARE SUB erreur2 ()
DECLARE SUB exact2 ()
DECLARE SUB fleches (v%, h%, w$(), np%, r%, coul%, drap%, v2%, h3%)
DECLARE SUB inputgen (nl%, r$, deb%, fin%, fond%)
DECLARE SUB ligne23 (x%, y%, z!)
DECLARE SUB Niveau (ni%, np%)
DECLARE SUB quitter (x%, y%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB solution (sol$)
DECLARE SUB titre ()
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB consigne (nl%, w$, z$, y$)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB regle1 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB regle2 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB correction (donnee$)
DECLARE SUB MouseBorder (row1%, col1%, row2%, col2%)
DECLARE SUB MouseHide ()
DECLARE SUB MousePoll (row%, col%, lButton%, rButton%)
DECLARE SUB MouseShow ()
'EXE 3 MATH aas pr
'5/5/96
'Daniel CLERC
'version 1.0


DEFINT A-Z
SUB moitie (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'8/12/96
DIM re$(20), s!(3), s$(3)

'niveau
CALL Niveau(ni, 3)
SELECT CASE ni
CASE 1
valeur = 10
CASE 2
valeur = 100
CASE 3
valeur = 1
END SELECT

GOSUB moitiedebut

CALL titre

FOR ii = 1 TO 10 '++++++++
MouseHide
CALL niv(10, ii)

SELECT CASE ni

CASE 1
IF ii < 6 THEN plus = 0 ELSE plus = 1 'les 5 premiers coups faciles (dizaines paires)
DO
DO
DO
di = (INT(RND * 5)) * 2 + plus
LOOP WHILE di = di2
di2 = di
DO
un = (INT(RND * 5)) * 2
LOOP WHILE un = un2
un2 = un
LOOP WHILE di = 0 OR un = 0
ha = (di * 10) + un
LOOP WHILE ha = n OR ha < 20

n = ha

CASE 2
DO
ha = (INT(RND * 500)) * 2
LOOP WHILE ha = n OR ha < 100
n = ha

CASE 3 'nombre impair
DO
ha = (INT(RND * 50) * 2) + 1
LOOP WHILE ha = n OR ha < 30
n = ha

END SELECT

CALL cadre(7, 25, 10, 2, vert)
COLOR blancbrill, vert
LOCATE 8, 28: PRINT "Nombre"
CALL cadre(7, 44, 10, 2, vert)
COLOR blancbrill, vert
LOCATE 8, 47: PRINT "Moitié"
COLOR , bleu

LOCATE 17
FOR i = 1 TO 3
PRINT SPACE$(80)
NEXT
COLOR jaune
LOCATE 17, 40: PRINT "?"
COLOR vertclair
LOCATE 18, 28
PRINT "0"; : COLOR blanc: PRINT "├" + STRING$(10, "─") + "┴" + STRING$(10, "─") + "┤"
COLOR vertclair
LOCATE 18, 52: PRINT LTRIM$(STR$(n)); " "

CALL cadre(10, 25, 10, 4, rouge)
CALL cadre(10, 44, 10, 4, blanc)

LOCATE 12, 28: COLOR blancbrill, rouge: PRINT n

moi1:
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")

DO
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

' COLOR noir, blanc
' LOCATE 12, 48: PRINT "_"
LOCATE 12, 48
CALL inputgen(5, r$, 44, 57, blanc)
CALL ligne23(noir, noir, 0)

CALL convertir2(r$)
z! = VAL(r$)
z$ = LTRIM$(STR$(z!)): CALL convertir(z$)

IF z! >= n OR z! < 1 THEN
CALL centre(23, rougeclair, "Tu dois taper la moitié du nombre.")
CALL attendre(1.5)
GOTO moi1
END IF

empl = INT((10 / (n / 2)) * z!)

COLOR jaune, bleu
LOCATE 17, 40: PRINT "?"
LOCATE 19, 1: PRINT SPACE$(80)
COLOR vertclair: LOCATE 18, 28: PRINT "0"; : COLOR blanc
IF z! = n / 2 THEN
PRINT "├" + STRING$(10, "─") + "┴" + STRING$(10, "─") + "┤"
COLOR jaune
LOCATE 17, 42 - LEN(z$)
PRINT z$
ELSEIF z! < n / 2 THEN
PRINT "├";
IF empl <> 0 THEN PRINT STRING$(empl, "─");
PRINT "┬" + STRING$(9 - empl, "─") + "┴" + STRING$(10, "─") + "┤"
COLOR rougeclair
LOCATE 19, 30 + empl: PRINT z$
ELSEIF z! > n / 2 THEN
PRINT "├"; STRING$(10, "─"); "┴"; STRING$(empl - 10, "─");
PRINT "┬" + STRING$(19 - empl, "─") + "┤"
COLOR rougeclair
LOCATE 19, 31 + empl: PRINT z$
END IF
COLOR vertclair
LOCATE 18, 52: PRINT LTRIM$(STR$(n))
COLOR , noir

IF z! = n / 2 THEN
CALL exact2
IF cc = 0 THEN re = re + 1
EXIT DO
ELSE
GOSUB moisol
END IF
LOOP

cc = 0

NEXT ii '+++++++

re = INT(re / 2)
CALL resultats(re, ni, 3)

EXIT SUB

moisol:
cc = cc + 1
n$ = LTRIM$(STR$(n)): w$ = ""

IF cc < 2 THEN
CALL erreur2
ELSEIF cc = 2 THEN
w$ = n$ + " = ": GOSUB aidesol
ELSEIF cc = 3 THEN
w$ = "Solution =": GOSUB aidesol2
ELSE
BEEP
w! = n / 2: w$ = STR$(w!): CALL convertir(w$)
CALL centre(23, rougeclair, "Solution :" + w$)
END IF
RETURN

aidesol:
IF LEN(n$) = 3 THEN
w$ = w$ + LEFT$(n$, 1) + "00 + " + MID$(n$, 2, 1)
ELSE
w$ = w$ + LEFT$(n$, 1)
END IF
w$ = w$ + "0 + " + RIGHT$(n$, 1)
CALL centre(23, rougeclair, w$)
RETURN

aidesol2:
IF LEN(n$) = 3 THEN
s!(1) = (VAL(LEFT$(n$, 1)) * 100) / 2
s$(1) = STR$(s!(1))
s!(2) = (VAL(MID$(n$, 2, 1)) * 10) / 2
s$(2) = STR$(s!(2))
s!(3) = (VAL(RIGHT$(n$, 1))) / 2
s$(3) = STR$(s!(3)): CALL convertir(s$(3))
ELSE
s!(1) = (VAL(LEFT$(n$, 1)) * 10) / 2
s$(1) = STR$(s!(1))
s!(2) = (VAL(RIGHT$(n$, 1))) / 2
s$(2) = STR$(s!(2)): CALL convertir(s$(2))
END IF
FOR i = 1 TO LEN(n$)
w$ = w$ + s$(i)
IF i < LEN(n$) THEN w$ = w$ + " +"
NEXT
CALL centre(23, rougeclair, w$)
RETURN

moitiedebut: 'écrire la moitié des dizaines, centaines ou unités
re = 1 '9 essais

cc = 0
CALL titre
MouseHide
'dessin des cadres
v = 6: h = 10
FOR i = 1 TO 9
CALL cadre(v, h, 4, 4, rouge)
IF valeur = 100 THEN
LOCATE v + 2, h + 1
ELSE
LOCATE v + 2, h + 2
END IF
COLOR , rouge
PRINT LTRIM$(RTRIM$(STR$(valeur * i)))
h = h + 8
NEXT
v = 14: h = 10
FOR i = 1 TO 9
COLOR vertclair, bleu
LOCATE v - 2, h + 2: PRINT CHR$(25)
CALL cadre(v, h, 4, 4, blanc)
h = h + 8
NEXT
COLOR vertclair, bleu
LOCATE v + 2, 2: PRINT "Moitié"
COLOR , noir

h = 12
FOR boucle = 1 TO 9 '/////////////

DO
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &h30) 'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG
IF valeur = 100 THEN
LOCATE 16, h - 1
CALL inputgen(4, r$, 44, 57, blanc)
ELSE
LOCATE 16, h
CALL inputgen(3, r$, 44, 57, blanc)
END IF

CALL convertir2(r$)
z! = VAL(r$)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF z! = ((boucle * valeur) / 2) THEN
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
ELSE
cc = cc + 1
IF cc = 1 THEN
IF z! = ((boucle * valeur) * 2) THEN
CALL centre(23, rougeclair, "Tu as tapé le double !")
CALL attendre(1.5)
ELSE
CALL erreur2
END IF
ELSE
z$ = STR$((boucle * valeur) / 2): CALL convertir(z$)
CALL solution(z$)
CALL attendre(1.5)
END IF
END IF
LOOP
h = h + 8
NEXT boucle '//////////
CALL attendre(1)

RETURN

END SUB

DEFINT A-Z
SUB nombrechiffre (re%, ni%, un$(), di$(), ex$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)
DIM re$(12), p(2), tr$(3), m$(40)
'4/5/96
z$ = "0000000000": nl = 11

re = 0: cc = 0

CALL Niveau(ni, 3)
IF ni = 1 THEN ti = 3
IF ni = 2 THEN ti = 6
IF ni = 3 THEN ti = 9

MouseHide
FOR r = 1 TO 10 '+++++++++++++++++
CALL titre

CALL niv(10, r)

GOSUB chiftirage: GOSUB chiftrans
m$ = n2$ + " ": GOSUB chiftrouvemot
GOSUB chifaffor

chif4:
COLOR , noir
IF cc < 3 THEN
LOCATE 22, 1: PRINT SPACE$(80): PRINT SPACE$(80)
CALL centre(23, blanc, "Tape le nombre en chiffres")
END IF

IF y& >= 1000000 THEN
nl = LEN(n$) + 2
ELSEIF y& >= 1000 THEN
nl = LEN(n$) + 1
ELSE
nl = LEN(n$)
END IF

DO
CALL cadre(13, 32, 15, 4, blanc)
COLOR noir, blanc
h = INT(41 - (nl / 2))
LOCATE 15, h
PRINT ligne$
LOCATE 15, h
GOSUB inpu
LOOP WHILE ASC(r$) = 13 OR ASC(r$) = 27

zz# = VAL(r$)

IF zz# = 0 THEN GOTO chif4
IF zz# > 999999999 THEN BEEP: GOTO chif4

zz& = zz#
b$ = LTRIM$(STR$(zz&))

COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF zz& = y& THEN
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
ELSE
cc = cc + 1
IF cc = 1 THEN
GOSUB chifaffor
COLOR , noir
GOSUB chifaide2
ELSE
CALL centre(23, rougeclair, "Solution : " + rep$)
CALL getinvimouse(w)
END IF
GOTO chif4
END IF
NEXT r '+++++++++++++++++++++

CALL resultats(re, ni, 3)

EXIT SUB

inpu:
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
LOCATE , , 1
FOR ii = 1 TO nl + 1
chif0:
IF ii <= 0 THEN ii = 1
chif1:
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

DO
re$(ii) = INKEY$
LOOP WHILE re$(ii) = ""
IF ASC(re$(ii)) = 27 THEN CALL quitter(noir, blanc): r$ = CHR$(27): RETURN
IF LEN(re$(ii)) = 2 THEN z2 = ASC(RIGHT$(re$(ii), 1)): IF ii > 1 AND (z2 = 75 OR z2 = 83 OR z2 = 15) THEN PRINT CHR$(29); " "; CHR$(29); : ii = ii - 1: z2 = 0: GOTO chif0 ELSE GOTO chif0
IF ASC(re$(ii)) = 13 THEN GOTO chif3
IF ii > 1 AND ASC(re$(ii)) = 8 THEN PRINT CHR$(29); " "; CHR$(29); : ii = ii - 1: GOTO chif0 ELSE IF ASC(re$(ii)) = 8 THEN GOTO chif0
IF ASC(re$(ii)) < 48 OR ASC(re$(ii)) > 57 THEN CALL chiffreslettres(noir, bleu, 1): r$ = CHR$(27): RETURN
IF ii = nl + 1 THEN BEEP: GOTO chif1
PRINT re$(ii);
f = -1
IF LEN(n$) = 9 AND (ii = 3 OR ii = 7) THEN f = 0
IF LEN(n$) = 8 AND (ii = 2 OR ii = 6) THEN f = 0
IF LEN(n$) = 7 AND (ii = 1 OR ii = 5) THEN f = 0
IF (LEN(n$) = 6 AND ii = 3) OR (LEN(n$) = 5 AND ii = 2) OR (LEN(n$) = 4 AND ii = 1) THEN f = 0
IF f = 0 THEN ii = ii + 1: re$(ii) = " ": PRINT re$(ii);
NEXT ii
chif3:
PRINT
r$ = "": FOR jj = 1 TO ii - 1: r$ = r$ + re$(jj): NEXT
r$ = LTRIM$(r$): r$ = RTRIM$(r$)
IF r$ = "" THEN r$ = CHR$(13)
LOCATE , , 0
RETURN

chifanalyse:
no$ = ""
FOR i = 2 TO 0 STEP -1
p(i) = VAL(MID$(tr$, 3 - i, 1))
NEXT
IF p(2) = 0 THEN GOTO chif10
IF p(2) = 1 THEN no$ = "cent ": GOTO chif10
no$ = un$(p(2)) + "cent"
IF p(0) <> 0 OR p(1) <> 0 THEN no$ = no$ + " ": GOTO chif10
IF f = -1 THEN no$ = no$ + "s"
no$ = no$ + " "
chif10:
IF p(1) = 0 THEN GOTO chif11
IF p(1) = 7 AND p(0) = 1 THEN no$ = no$ + di$(p(1) - 1) + "et " + ex$(p(0)): RETURN
IF p(1) = 1 AND (p(0) > 0 AND p(0) < 7) THEN no$ = no$ + ex$(p(0)): RETURN
IF (p(1) = 7 OR p(1) = 9) AND (p(0) > 0 AND p(0) < 7) THEN no$ = no$ + di$(p(1) - 1) + ex$(p(0)): RETURN
IF p(0) = 1 AND (p(1) <> 0 AND p(1) <> 8) THEN no$ = no$ + di$(p(1)) + "et ": GOTO chif11
no$ = no$ + di$(p(1))
IF f = -1 AND (p(1) = 8 AND p(0) = 0) THEN no$ = LEFT$(no$, LEN(no$) - 1) + "s "
chif11:
IF p(0) = 0 THEN RETURN
no$ = no$ + un$(p(0))
RETURN

chiftrans:
'nombre en lettres
n$ = MID$(STR$(y&), 2): n1$ = LEFT$(z$, 10 - LEN(n$)) + n$: n2$ = ""
i = 0
FOR j = 1 TO 7 STEP 3
tr$(i) = MID$(n1$, 9 - j, 3)
i = i + 1
NEXT
'_unités simples_
f = -1: tr$ = tr$(0)
IF VAL(tr$) = 0 THEN GOTO chif12
GOSUB chifanalyse
n2$ = no$
chif12:
f = 0: tr$ = tr$(1): IF VAL(tr$) = 0 THEN GOTO chif13
IF VAL(tr$) = 1 THEN n2$ = "mille " + n2$: GOTO chif13
GOSUB chifanalyse
n2$ = no$ + "mille " + n2$
chif13:
tr$ = tr$(2): IF VAL(tr$) = 0 THEN GOTO chif14
IF VAL(tr$) = 1 THEN n2$ = "un million " + n2$: GOTO chif14
GOSUB chifanalyse
n2$ = no$ + "millions " + n2$
chif14:
n2$ = MID$(n2$, 1, LEN(n2$) - 1)

'nombre en chiffre
rep$ = ""
SELECT CASE ni
CASE 1
rep$ = LTRIM$(STR$(y&))

CASE 2
IF LEFT$(tr$(1), 2) = "00" THEN
rep$ = MID$(tr$(1), 3)
ELSEIF LEFT$(tr$(1), 1) = "0" THEN
rep$ = MID$(tr$(1), 2)
ELSE
rep$ = tr$(1)
END IF
rep$ = rep$ + " " + tr$(0)

CASE 3
IF LEFT$(tr$(2), 2) = "00" THEN
rep$ = MID$(tr$(2), 3)
ELSEIF LEFT$(tr$(2), 1) = "0" THEN
rep$ = MID$(tr$(2), 2)
ELSE
rep$ = tr$(2)
END IF
rep$ = rep$ + " " + tr$(1) + " " + tr$(0)
END SELECT

'tranformer la ligne de points
ligne$ = MID$("............", 1, LEN(rep$))
x = 1
DO
s = INSTR(x, rep$, " ")
IF s <> 0 THEN
ligne$ = MID$(ligne$, 1, s - 1) + " " + MID$(ligne$, s + 1)
x = s + 1
ELSE
EXIT DO
END IF
LOOP

RETURN

chiftirage:
DO
z& = INT(RND * 10 ^ ti) + 1
LOOP WHILE z& = y&
y& = z&
IF ni = 1 AND y& < 100 THEN GOTO chiftirage
IF ni = 2 AND y& < 1000 THEN GOTO chiftirage
IF ni = 3 AND y& < 100000 THEN GOTO chiftirage
RETURN

chifaide2:
z1 = 0
FOR ii = 1 TO LEN(n$)
IF MID$(n$, ii, 1) = "0" THEN z1 = z1 + 1
NEXT
z2 = 0
FOR ii = 1 TO LEN(b$)
IF MID$(b$, ii, 1) = "0" THEN z2 = z2 + 1
NEXT
IF LEN(n$) = LEN(b$) AND z1 <= z2 THEN
CALL erreur2
RETURN
END IF

COLOR rougeclair
f1 = 0: f2 = 0
IF LEN(n$) <> LEN(b$) THEN
f1 = 1
END IF

IF z1 AND (z1 - z2) > 0 THEN
f2 = 1
w$ = ""
w$ = STR$(z1 - z2) + " zéro": IF z1 - z2 > 1 THEN w$ = w$ + "s"
w$ = w$ + " oublié": IF z1 - z2 > 1 THEN w$ = w$ + "s." ELSE w$ = w$ + "."
END IF

IF f1 = 0 AND f2 = 0 THEN RETURN
IF f1 = 1 AND f2 = 0 THEN
CALL centre(23, rougeclair, "Il faut" + STR$(LEN(n$)) + " chiffres.")
ELSEIF f1 = 0 AND f2 = 1 THEN
CALL centre(23, rougeclair, w$)
ELSEIF f1 = 1 AND f2 = 1 THEN
CALL centre(22, rougeclair, "Il faut" + STR$(LEN(n$)) + " chiffres.")
CALL centre(23, rougeclair, w$)
END IF
CALL getinvimouse(w)
RETURN

chiftrouvemot:
j = 1: MM$ = ""
FOR i = 1 TO LEN(m$)
MM$ = MM$ + MID$(m$, i, 1)
IF ASC(MID$(m$, i, 1)) = 32 THEN m$(j) = MID$(MM$, 1, LEN(MM$) - 1): MM$ = "": j = j + 1: IF LEN(m$(j - 1)) = 0 THEN j = j - 1
NEXT
nm = j - 1
RETURN

chifaffor:
IF LEN(n2$) < 74 THEN
CALL cadre(7, INT(41 - LEN(n2$) / 2) - 3, LEN(n2$) + 4, 2, rouge)
COLOR , rouge
LOCATE 8, INT(41 - LEN(n2$) / 2)
ELSE
COLOR blancbrill, rouge
LOCATE 7, 1
PRINT SPACE$(80): PRINT SPACE$(80): PRINT SPACE$(80)
IF LEN(n2$) > 80 THEN PRINT SPACE$(80)
LOCATE 8
END IF

i = 1: l2 = 0
chif7:
l = LEN(m$(i))
l2 = l2 + l
IF l2 > 80 THEN PRINT : i = i - 1: l2 = 0: GOTO chif6
IF l2 = 80 AND cc > 0 THEN
IF LEFT$(m$(i), 4) = "mill" THEN
IF couleur = 0 THEN COLOR noir, blanc ELSE COLOR blancbrill, vert
END IF
END IF
IF l2 = 80 THEN PRINT m$(i); : COLOR blancbrill, rouge: l2 = 0: GOTO chif6
IF l2 = 80 - 1 AND cc > 0 THEN
IF LEFT$(m$(i), 4) = "mill" THEN
IF couleur = 0 THEN COLOR noir, blanc ELSE COLOR blancbrill, vert
END IF
END IF
IF l2 = 80 - 1 THEN PRINT m$(i): COLOR blancbrill, rouge: l2 = 0: GOTO chif6
IF cc > 0 AND LEFT$(m$(i), 4) = "mill" THEN
IF couleur = 0 THEN COLOR noir, blanc ELSE COLOR blancbrill, vert
END IF
PRINT m$(i); : COLOR blancbrill, rouge: PRINT " "; : l2 = l2 + 1
chif6:
i = i + 1: IF i <= nm THEN GOTO chif7
PRINT
COLOR , noir
RETURN

END SUB

DEFINT A-Z
SUB regle (re%, ni%, flagscreen%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'17/1/96
re = 0
IF flagscreen = 0 THEN
CALL Niveau(ni, 2)
COLOR , noir

SELECT CASE ni
CASE 1
CALL regle1(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
CASE 2
CALL regle2(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
END SELECT

CALL resultats(re, ni, 2)
ELSE
CALL regle1(re%, 1, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
CALL resultats(re, 1, 1)
END IF
END SUB

DEFINT A-Z
SUB regle1 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'24/11/96
CONST gauche = 75, droite = 77
sigle$ = CHR$(24): b2$ = CHR$(179): l2$ = SPACE$(73)

re = 0

CALL titre

FOR ii = 1 TO 10 '+++++++++++++
CALL niv(10, ii)
ne = 0
COLOR , bleu
LOCATE 7, 1: PRINT SPACE$(80)
LOCATE 12, 1: PRINT SPACE$(80)

n = INT(RND * 90)
n2! = n + INT(RND * 7) + INT(RND * 10) / 10
n2$ = LTRIM$(STR$(n2!))

CALL convertir(n2$)
COLOR , noir
CALL centre(7, jaune, " Cherche le nombre : " + n2$ + " ")
COLOR blancbrill, bleu

LOCATE 12, 4

FOR i = n TO n + 6
IF LEN(LTRIM$(STR$(i))) = 1 THEN
PRINT LTRIM$(STR$(i)); b2$; " ";
ELSE
PRINT MID$(LTRIM$(STR$(i)), 1, 1); b2$; MID$(LTRIM$(STR$(i)), 2, 1); " ";
END IF
NEXT

IF LEN(LTRIM$(STR$(i))) = 1 THEN
PRINT LTRIM$(STR$(i)); b2$
ELSE
PRINT MID$(LTRIM$(STR$(i)), 1, 1); b2$; MID$(LTRIM$(STR$(i)), 2, 1)
END IF

LOCATE , 5: PRINT STRING$(71, 179)
h = 5

reg1:

COLOR , noir
CALL centre(23, blanc, CHR$(27) + " " + CHR$(26) + " puis " + rt$)
COLOR blancbrill

DO
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

LOCATE 14, 4: PRINT l2$: LOCATE 14, h: COLOR vertclair: PRINT sigle$: COLOR blancbrill

IF ne > 1 THEN
n3! = n + (h - 5) / 10
n3$ = LTRIM$(STR$(n3!))
CALL convertir(n3$)
CALL centre(18, jaune, " " + n3$ + " ")
END IF

DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
IF v_mouse = 23 THEN
IF h_mouse = 35 THEN
'fleche gauche
rr = gauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche droite
rr = droite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 44 AND h_mouse <= 46 THEN
'entree
rr = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSEIF v_mouse >= 12 AND v_mouse <= 14 THEN
IF h_mouse >= 5 AND h_mouse <= 75 THEN
h = h_mouse
LOCATE 14, 4: PRINT l2$: LOCATE 14, h: COLOR vertclair: PRINT sigle$: COLOR blancbrill
CALL attendre(.3)
souris = 2
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN EXIT DO

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE rr

CASE gauche
IF h = 5 THEN
h = 75
ELSEIF h > 5 THEN
h = h - 1
END IF

CASE droite
IF h = 75 THEN
h = 5
ELSEIF h < 75 THEN
h = h + 1
END IF

CASE 27
CALL quitter(noir, noir)

CASE 13
EXIT DO

END SELECT
LOOP


LOCATE 23: PRINT l2$
n3! = n + (h - 5) / 10
n3$ = LTRIM$(STR$(n3!))
CALL convertir(n3$)

IF n2! <> n3! THEN
BEEP: LOCATE 23, 18: COLOR rougeclair
PRINT "Tu as indiqué le nombre "; : COLOR jaune: PRINT n3$; : COLOR rougeclair: PRINT " au lieu de "; : COLOR jaune: PRINT n2$
CALL getinvimouse(w)
ne = ne + 1: LOCATE 23, 1: PRINT l2$
GOTO reg1
ELSE
CALL centre(23, jaune, "Exact")
CALL attendre(.7)
IF ne = 0 THEN re = re + 1
END IF
NEXT ii '++++++

END SUB

DEFINT A-Z
SUB regle2 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'26/11/96
CONST gauche = 75, droite = 77
DIM un(1 TO 30) AS INTEGER
DIM deux(1 TO 30) AS INTEGER
DIM trois(1 TO 30) AS INTEGER
DIM quatre(1 TO 30) AS INTEGER
DIM cinq(1 TO 30) AS INTEGER
DIM six(1 TO 30) AS INTEGER
DIM sept(1 TO 30) AS INTEGER
DIM huit(1 TO 30) AS INTEGER
DIM neuf(1 TO 30) AS INTEGER
DIM zero(1 TO 30) AS INTEGER
DIM barre(1 TO 30) AS INTEGER
DIM fleche(1 TO 30) AS INTEGER
DIM espace(1 TO 30) AS INTEGER

cc = 0

SCREEN 9, , 0, 1
'mémorisation des lettres : matrice 8 x 14
x = 0: y = 0
COLOR jaune 'blancbrill
PRINT "1 2 3 4 5 6 7 8 9 0 │ "; CHR$(24); " "
GET (x, y)-(x + 7, y + 13), un
x = x + 16
GET (x, y)-(x + 7, y + 13), deux
x = x + 16
GET (x, y)-(x + 7, y + 13), trois
x = x + 16
GET (x, y)-(x + 7, y + 13), quatre
x = x + 16
GET (x, y)-(x + 7, y + 13), cinq
x = x + 16
GET (x, y)-(x + 7, y + 13), six
x = x + 16
GET (x, y)-(x + 7, y + 13), sept
x = x + 16
GET (x, y)-(x + 7, y + 13), huit
x = x + 16
GET (x, y)-(x + 7, y + 13), neuf
x = x + 16
GET (x, y)-(x + 7, y + 13), zero
x = x + 16
GET (x, y)-(x + 7, y + 13), barre
x = x + 16
GET (x, y)-(x + 7, y + 13), fleche
x = x + 16
GET (x, y)-(x + 7, y + 13), espace

LOCATE 1: PRINT SPACE$(26)

SCREEN 9, , 0, 0

FOR no = 1 TO 10 '///////////////////////
ne = 0: h = 0
LINE (0, 14)-(640, 27), vert, BF
CALL centre(2, jaune, " REGLE GRADUEE ")
LINE (0, 28)-(639, 279), bleu, BF
LINE (0, 279)-(640, 292), vert, BF
COLOR blancbrill

COLOR vertclair: LOCATE 22: PRINT "Niveau"; ni
LOCATE 22, 77: PRINT 11 - no

'tirage nombre
n = INT(RND * 70) + 10
SELECT CASE INT(RND * 3)
CASE 0, 1
sol! = n + INT(RND * 9) / 10 + INT(RND * 9) / 100
CASE 2
sol! = n + INT(RND * 9) / 10
END SELECT

sol$ = LTRIM$(STR$(sol!))
CALL convertir(sol$)

CALL centre(8, jaune, " Cherche le nombre : " + sol$ + " ")
COLOR blancbrill

'tirage de l'endroit du nombre
z = INT(RND * 5)
x = (z * 40) + 36 + 4
LINE (x, 163)-(x, 170)
b$ = LTRIM$(STR$(n))
GOSUB regl4
x = x + 200
'on trace le petit trait
LINE (x, 164)-(x, 170)
x = x + 200
LINE (x, 163)-(x, 170)
b$ = LTRIM$(STR$(n + 1))
GOSUB regl4

'calcul de la 1° valeur en fonction de z et de n2!
n3! = n - (z * .1)

x = 40: y = 150 + 28
FOR j = 1 TO 14
LINE (x, y - 10)-(x, y)
x = x + 4
FOR jj = 1 TO 4
LINE (x, y - 4)-(x, y)
x = x + 4
NEXT jj
LINE (x, y - 6)-(x, y)
x = x + 4
FOR jj = 1 TO 4
LINE (x, y - 4)-(x, y)
x = x + 4
NEXT jj
NEXT j
LINE (x, y - 10)-(x, y)

x = 36: y = 154 + 28
LOCATE 14, 5: PRINT SPACE$(73)

regl1:
MouseShow
CALL centre(23, blanc, CHR$(27) + " " + CHR$(26) + " puis " + rt$)
COLOR blancbrill

DO
DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

LOCATE 14, INT(x / 8): PRINT " "
PUT (x + 1, y), fleche, OR

IF ne > 1 THEN
n2$ = LTRIM$(STR$(n3! + (h * .01)))

'test bug langage
l = LEN(n2$)
s = INSTR(1, n2$, ".")
l2 = l - s 'calcul des décimales
IF l2 > 2 THEN
CALL correction(n2$)
END IF

CALL convertir(n2$)
CALL centre(18, jaune, SPACE$(7))
CALL centre(18, jaune, " " + n2$ + " ")
END IF

MouseBorder 170, 24, 180, 615
MouseShow
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
'LOCATE 18, 1: PRINT v_mouse, h_mouse'===
'réso EGA
IF lButton THEN
IF v_mouse >= 308 AND v_mouse <= 320 THEN
IF h_mouse >= 268 AND h_mouse <= 280 THEN
'fleche gauche
rr = gauche
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 284 AND h_mouse <= 296 THEN
'fleche droite
rr = droite
CALL attendre(.2)
souris = 1
EXIT DO
ELSEIF h_mouse >= 340 AND h_mouse <= 364 THEN
'entree
rr = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSEIF v_mouse >= 162 AND v_mouse <= 196 THEN
IF h_mouse >= 36 AND h_mouse <= 596 THEN
MouseHide
x = h_mouse - 3
h = h_mouse - 40: h = h / 4
LOCATE 14, 5: PRINT SPACE$(73)
PUT (x, y), fleche, OR
CALL attendre(.3)
souris = 2
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN EXIT DO

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE rr

CASE gauche
IF x = 36 THEN
x = 596
h = 140
LOCATE 14, 5: PRINT " "
ELSEIF x > 36 THEN
x = x - 4
h = h - 1
END IF

CASE droite
IF x = 596 THEN
x = 36
h = 0
LOCATE 14, 75: PRINT " "
ELSEIF x < 596 THEN
x = x + 4
h = h + 1
END IF

CASE 27
CALL quitter(noir, noir)

CASE 13
EXIT DO

END SELECT

LOOP

n2$ = LTRIM$(STR$(n3! + (h * .01)))

'test bug langage
l = LEN(n2$)
s = INSTR(1, n2$, ".")
l2 = l - s 'calcul des décimales
IF l2 > 2 THEN
CALL correction(n2$)
END IF

CALL convertir(n2$)

IF n2$ = sol$ THEN
CALL centre(23, jaune, SPACE$(20))
CALL centre(23, jaune, "Exact")
CALL attendre(.5)
CALL centre(23, 15, SPACE$(20))
IF ne = 0 THEN re = re + 1
ELSE
BEEP
LOCATE 23, 18: COLOR rougeclair
PRINT "Tu as indiqué le nombre "; : COLOR jaune: PRINT n2$; : COLOR rougeclair: PRINT " au lieu de "; : COLOR jaune: PRINT sol$
CALL getinvimouse(w)
ne = ne + 1: LOCATE 23, 1: PRINT SPACE$(76)
GOTO regl1
END IF

NEXT no

SCREEN 0

EXIT SUB

regl4:
y = 120 + 28: xx = x
FOR i = LEN(b$) TO 1 STEP -1
tt = VAL(MID$(b$, i, 1))
SELECT CASE tt
CASE 1
PUT (xx, y), un, OR
CASE 2
PUT (xx, y), deux, OR
CASE 3
PUT (xx, y), trois, OR
CASE 4
PUT (xx, y), quatre, OR
CASE 5
PUT (xx, y), cinq, OR
CASE 6
PUT (xx, y), six, OR
CASE 7
PUT (xx, y), sept, OR
CASE 8
PUT (xx, y), huit, OR
CASE 9
PUT (xx, y), neuf, OR
CASE 0
PUT (xx, y), zero, OR

END SELECT
xx = xx - 8
NEXT i
RETURN

END SUB

DEFINT A-Z
SUB soustraction2 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'5/6/95 'niveau avec retenues
MouseHide
DIM un(1 TO 30) AS INTEGER
DIM deux(1 TO 30) AS INTEGER
DIM trois(1 TO 30) AS INTEGER
DIM quatre(1 TO 30) AS INTEGER
DIM cinq(1 TO 30) AS INTEGER
DIM six(1 TO 30) AS INTEGER
DIM sept(1 TO 30) AS INTEGER
DIM huit(1 TO 30) AS INTEGER
DIM neuf(1 TO 30) AS INTEGER
DIM zero(1 TO 30) AS INTEGER
DIM moins(1 TO 30) AS INTEGER
DIM curseur(1 TO 30) AS INTEGER
DIM espace(1 TO 30) AS INTEGER
DIM retenue(1 TO 30) AS INTEGER
DIM retenue2(1 TO 30) AS INTEGER

ccc = 0: cc = 0: re = 0: f = 0
IF ni = 1 THEN
n1 = 3: n2 = 2
ELSEIF ni = 2 THEN
n1 = 3: n2 = 3
END IF

SCREEN 9, , 0, 1
'mémorisation des lettres : matrice 8 x 14
x = 0: y = 0
COLOR jaune 'blancbrill
PRINT "1 2 3 4 5 6 7 8 9 0 - _ █"
GET (x, y)-(x + 7, y + 13), un
x = x + 16
GET (x, y)-(x + 7, y + 13), deux
x = x + 16
GET (x, y)-(x + 7, y + 13), trois
x = x + 16
GET (x, y)-(x + 7, y + 13), quatre
x = x + 16
GET (x, y)-(x + 7, y + 13), cinq
x = x + 16
GET (x, y)-(x + 7, y + 13), six
x = x + 16
GET (x, y)-(x + 7, y + 13), sept
x = x + 16
GET (x, y)-(x + 7, y + 13), huit
x = x + 16
GET (x, y)-(x + 7, y + 13), neuf
x = x + 16
GET (x, y)-(x + 7, y + 13), zero
x = x + 16
GET (x, y)-(x + 7, y + 13), moins
x = x + 16
GET (x, y)-(x + 7, y + 13), curseur
x = x + 16
GET (x, y)-(x + 7, y + 13), espace

LOCATE 1: PRINT SPACE$(26)

x = 3: y = 0
LINE (x, y)-(x, y + 5), blanc
LINE (x + 1, y)-(x + 1, y + 5), blanc
LINE (x - 2, y + 2)-(x, y), blanc
GET (x - 2, y)-(x + 1, y + 5), retenue
LINE (x, y)-(x, y + 5), vertclair
LINE (x + 1, y)-(x + 1, y + 5), vertclair
LINE (x - 2, y + 2)-(x, y), vertclair
GET (x - 2, y)-(x + 1, y + 5), retenue2
LOCATE 1, 1: PRINT " "

SCREEN 9, , 0, 0

FOR no = 1 TO 5 '///////////////////////

LINE (0, 14)-(640, 27), vert, BF
CALL centre(2, jaune, " SOUSTRACTION ")
LINE (0, 28)-(639, 279), bleu, BF
LINE (0, 279)-(640, 292), vert, BF
COLOR blancbrill

COLOR vertclair: LOCATE 22: PRINT "Niveau"; ni
LOCATE 22, 77: PRINT 6 - no

'tirage
soustraction0:
DO
a = INT(RND * (10 ^ n1))
a$ = LTRIM$(STR$(a))
LOOP WHILE LEN(a$) <> n1
DO
b = INT(RND * (10 ^ n2))
b$ = LTRIM$(STR$(b))
LOOP WHILE LEN(b$) <> n2
IF a < b THEN GOTO soustraction0
IF ni = 2 THEN
DO
b = b - 1
b$ = LTRIM$(STR$(b))
LOOP WHILE RIGHT$(a$, 1) < RIGHT$(b$, 1)
IF LEN(b$) <> n2 THEN GOTO soustraction0
END IF

'oper posee
'1° nombre
x = 330: y = 120
FOR i = LEN(a$) TO 1 STEP -1
n = VAL(MID$(a$, i, 1))
SELECT CASE n
CASE 1
PUT (x, y), un, OR
CASE 2
PUT (x, y), deux, OR
CASE 3
PUT (x, y), trois, OR
CASE 4
PUT (x, y), quatre, OR
CASE 5
PUT (x, y), cinq, OR
CASE 6
PUT (x, y), six, OR
CASE 7
PUT (x, y), sept, OR
CASE 8
PUT (x, y), huit, OR
CASE 9
PUT (x, y), neuf, OR
CASE 0
PUT (x, y), zero, OR

END SELECT
x = x - 16
NEXT i

'2° nombre
x = 330: y = 140
FOR i = LEN(b$) TO 1 STEP -1
n = VAL(MID$(b$, i, 1))
SELECT CASE n
CASE 1
PUT (x, y), un, OR
CASE 2
PUT (x, y), deux, OR
CASE 3
PUT (x, y), trois, OR
CASE 4
PUT (x, y), quatre, OR
CASE 5
PUT (x, y), cinq, OR
CASE 6
PUT (x, y), six, OR
CASE 7
PUT (x, y), sept, OR
CASE 8
PUT (x, y), huit, OR
CASE 9
PUT (x, y), neuf, OR
CASE 0
PUT (x, y), zero, OR

END SELECT
x = x - 16
NEXT i
x = x - 16
PUT (x, y), moins, OR

LINE (x, y + 20)-(337, y + 20), vertclair

'boucle comparaison
cc = 0
r$ = LTRIM$(STR$(a - b))
l = LEN(r$)
IF l + 1 = n1 THEN r$ = "0" + r$: l = l + 1
IF l + 2 = n1 THEN r$ = "00" + r$: l = l + 2
IF l + 3 = n1 THEN r$ = "000" + r$: l = l + 3
b$ = "0" + b$
boucle = 0

x = 330: y = 170

FOR j = l TO 1 STEP -1 '++++++++++++++++++++++++

r1$ = MID$(r$, j, 1)

a1$ = MID$(a$, LEN(a$) - boucle, 1)
b1$ = MID$(b$, LEN(b$) - boucle, 1)

'traiter les retenues
IF VAL(a1$) = VAL(b1$) + VAL(r1$) THEN '1° cas : pas de retenue
CALL centre(23, blanc, "Tape la réponse")
ph$ = a1$ + " moins " + b1$ + " est égal à..."
ELSEIF VAL(a1$) + 10 = VAL(b1$) + VAL(r1$) THEN '2° cas : retenue en haut
PUT (x - 5, 118), retenue, OR
PUT (x - (16 + 5), 138), retenue2, OR
CALL centre(23, blanc, "Attention à la retenue en haut")
ph$ = LTRIM$(STR$(VAL(a1$) + 10)) + " moins " + b1$ + " est égal à..."

ELSEIF VAL(a1$) = (VAL(b1$) + 1) + VAL(r1$) THEN '3° cas : retenue en bas
CALL centre(23, blanc, "Attention à la retenue en bas")
ph$ = a1$ + " moins " + LTRIM$(STR$(VAL(b1$) + 1)) + " est égal à..."

ELSEIF VAL(a1$) + 10 = (VAL(b1$) + 1) + VAL(r1$) THEN '4° cas : 2 retenues
PUT (x - 5, 118), retenue, OR
PUT (x - (16 + 5), 138), retenue2, OR
CALL centre(23, blanc, "Attention aux 2 retenues")
ph$ = LTRIM$(STR$(VAL(a1$) + 10)) + " moins " + LTRIM$(STR$(VAL(b1$) + 1)) + " est égal à..."
END IF

soustraction1:

PUT (x, y), curseur, OR
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

re$ = INPUT$(1)
PUT (x, y), curseur, XOR

IF ASC(re$) = 27 THEN
CALL quitter(noir, noir)
GOTO soustraction1
END IF
IF ASC(re$) < 48 OR ASC(re$) > 57 THEN
CALL chiffreslettres(noir, noir, 1)
GOTO soustraction1
END IF

n = VAL(re$)
SELECT CASE n
CASE 1
PUT (x, y), un, OR
CASE 2
PUT (x, y), deux, OR
CASE 3
PUT (x, y), trois, OR
CASE 4
PUT (x, y), quatre, OR
CASE 5
PUT (x, y), cinq, OR
CASE 6
PUT (x, y), six, OR
CASE 7
PUT (x, y), sept, OR
CASE 8
PUT (x, y), huit, OR
CASE 9
PUT (x, y), neuf, OR
CASE 0
PUT (x, y), zero, OR

END SELECT

LOCATE 23, 1: PRINT SPACE$(80)
IF re$ = r1$ THEN
CALL exact2
ELSE
cc = cc + 1
ccc = ccc + 1
IF ccc > 2 THEN
BEEP
CALL centre(23, rougeclair, "Solution : " + r1$)
ELSE
CALL erreur2
CALL centre(23, rougeclair, ph$)
END IF
PUT (x, y), espace, OR
PUT (x, y), espace, XOR
GOTO soustraction1
END IF

boucle = boucle + 1: ccc = 0
x = x - 16
NEXT j '++++++++++++++++++++++++++++=

'resultats
COLOR ' , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
COLOR rougeclair
LOCATE 23, 32
PRINT "Tu as fait"; cc; "erreur"; : IF cc > 1 THEN PRINT "s";
PRINT "."
END IF
cc = 0

CALL getinvimouse(w)
LOCATE 23, 1: PRINT SPACE$(80)
NEXT no '++++++++++++++++++

SCREEN 0
CALL resultats(re, ni, 3)


END SUB

DEFINT A-Z
SUB tables1 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DIM p$(15), z(10), ta(3)
'10/04/96
titr$ = "Tables de multiplication"
re = 0: cc = 0

'niveau
CALL Niveau(ni, 4)

SELECT CASE ni
CASE 1
GOSUB compte
CASE 2
ta(1) = 2: ta(2) = 3: ta(3) = 10
GOSUB tables
CASE 3
ta(1) = 4: ta(2) = 5: ta(3) = 6
GOSUB tables
CASE 4
ta(1) = 7: ta(2) = 8: ta(3) = 9
GOSUB tables
END SELECT

'résultats
re = INT(re / 3)

CALL resultats(re, ni, 4)
EXIT SUB

tables:
'rappel

CALL titre
CALL cadre(5, 4, 72, 14, rouge)
COLOR , rouge
h = 12
FOR ii = 1 TO 3
ta = ta(ii): ta$ = LTRIM$(STR$(ta))
COLOR noir, blanc
LOCATE 6, h - 2: PRINT " Table des "; ta$; " "
COLOR blancbrill, rouge
LOCATE 8
FOR j = 0 TO 10
LOCATE , h - LEN(STR$(j)): PRINT j; "x "; : COLOR jaune: PRINT ta$; : COLOR blancbrill: PRINT " = ";
LOCATE , (h + 8 + LEN(ta$)) - LEN(LTRIM$(STR$(ta * j))): PRINT LTRIM$(STR$(ta * j))
NEXT j
h = h + 24
NEXT ii
COLOR , noir
CALL centre(23, blanc, "Mémorise")
CALL getinvimouse(w)

FOR boucle = 1 TO 3 '+++++++++++
ta = ta(boucle): ta$ = LTRIM$(STR$(ta))

CALL titre
MouseHide
CALL cadre(10, 30, 20, 4, rouge)
COLOR , rouge
CALL centre(12, jaune, "Table des " + ta$ + " ")
CALL attendre(1.5)
CALL titre

'questions
FOR ii = 1 TO 10 '++++++++++++++
MouseHide
CALL niv(10, ii)
CALL cadre(6, 33, 14, 2, vert)
COLOR , vert
CALL centre(7, blancbrill, "Table des " + ta$ + " ")

'tirage
DO
f = 0
z(ii) = INT(RND * 10) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1

ha = z(ii)
ha$ = LTRIM$(STR$(ha))

DO
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")
COLOR , bleu
VIEW PRINT 13 TO 20
CLS 2
VIEW PRINT
CALL cadre(9, 33, 14, 4, blanc)

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &h30) 'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG
COLOR noir, blanc
LOCATE 11, 35: PRINT ha$; " x "; ta$; " = ";
CALL inputgen(3, r$, 48, 57, blanc)
r = VAL(r$)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF r = (ta * ha) THEN
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
ELSE
cc = 1
CALL centre(23, rougeclair, "Mémorise"): COLOR blancbrill, bleu
CALL cadre(14, 10, 60, 6, rouge)
COLOR blancbrill, rouge
LOCATE 15
FOR j = 1 TO 5
LOCATE , (22 - LEN(STR$(j))): PRINT j; "x "; ta$; " = ";
LOCATE , (30 + LEN(ta$)) - LEN(LTRIM$(STR$(ta * j))): PRINT LTRIM$(STR$(ta * j))
NEXT
LOCATE 15
FOR j = 6 TO 10
LOCATE , (51 - LEN(STR$(j))): PRINT j; "x "; ta$; " = ";
LOCATE , (59 + LEN(ta$)) - LEN(LTRIM$(STR$(ta * j))): PRINT LTRIM$(STR$(ta * j))
NEXT
CALL getinvimouse(w): IF w = 27 THEN CALL quitter(noir, noir)
END IF
LOOP
NEXT ii '+++++++++
NEXT boucle

RETURN

compte: 'compter de .. en ..
re = 3

FOR ii = 1 TO 3 '+++++++++
cc = 0
CALL titre
MouseHide
CALL niv(3, ii)
COLOR blancbrill
'dessin des cadres
v = 10: h = 2
FOR i = 1 TO 10
COLOR vertclair, bleu
LOCATE v - 1, h + 1: PRINT i
CALL cadre(v, h, 4, 4, blanc)
h = h + 8
NEXT
'tirage
SELECT CASE ii
CASE 1
valeur = 2
CASE 2
valeur = 4
CASE 3
valeur = 7
END SELECT

DO
f = 0
z(ii) = INT(RND * 3) + valeur
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1

ha = z(ii)
ha$ = LTRIM$(STR$(ha))

CALL cadre(5, 25, 30, 2, marron)
COLOR , marron
CALL centre(6, blancbrill, "Compte de " + ha$ + " en " + ha$)
COLOR noir, blanc

LOCATE 12, 4: PRINT ha$

h = 12
FOR boucle = 2 TO 10 '/////////////
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")

DO
COLOR noir, blanc

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &h30) 'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG

LOCATE 12, h

CALL inputgen(3, r$, 48, 57, blanc)
r = VAL(r$)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF r = (boucle * ha) THEN
CALL exact2
IF cc = 0 THEN re = re + 1
cc = 0
EXIT DO
ELSE
cc = cc + 1
IF cc = 1 THEN
CALL erreur2
w$ = "": w2$ = ""
IF boucle > 2 THEN
w2$ = LTRIM$(STR$(ha * (boucle - 1))) + " + " + LTRIM$(STR$(ha)) + " = "
END IF
FOR k = 1 TO boucle - 1
w$ = w$ + LTRIM$(STR$(ha)) + " + "
NEXT
w$ = w$ + LTRIM$(STR$(ha)) + " = "

w$ = w2$ + w$ + LTRIM$(STR$(ha)) + " x " + LTRIM$(STR$(boucle))
CALL centre(23, rougeclair, w$)
CALL attendre(1)
ELSE
CALL solution(STR$(ha * boucle))
CALL attendre(1)
END IF
END IF
LOOP
h = h + 8
NEXT boucle '//////////
CALL attendre(1.5)
NEXT ii '+++++++++++

RETURN

END SUB

DEFINT A-Z
SUB tables2 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'11/4/96
DIM re$(3 + 1), ca(5, 5), n(11), d(11), p$(2), z(11)
CONST gauche = 75, droite = 77, bas = 80, haut = 72
titr$ = "Tableau de multiplications"

l1$ = " ─┼────┼────┼────┼────┼────┼────┤"

l0$ = " │ │ │ │ │ │ │"

l4$ = " ─┴────┴────┴────┴────┴────┴────┘"

ff$ = CHR$(24) + " " + CHR$(25) + " " + CHR$(27) + " " + CHR$(26)
FOR i = 0 TO 5
FOR j = 0 TO 5
ca(i, j) = 0
NEXT j, i

re = 10
CALL titre
'niveau
p$(1) = "Tableau de 0 à 5": p$(2) = "Tableau de 6 à 11"
CALL cadre(7, 25, 30, 2, vert)
COLOR , vert
CALL centre(8, blancbrill, "Niveau de difficulté")
CALL fleches(13, 32, p$(), 2, ni, rouge, 1, 23, 35)

FOR ii = 1 TO 6
DO
f = 0
z(ii) = INT(RND * 6)
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT j
LOOP WHILE f = 1
NEXT ii
FOR i = 1 TO 6
IF ni = 1 THEN
n(i - 1) = z(i)
ELSE
n(i + 5) = z(i) + 6
END IF
NEXT

FOR ii = 1 TO 6
DO
f = 0
z(ii) = INT(RND * 6)
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT j
LOOP WHILE f = 1
NEXT ii
FOR i = 1 TO 6
IF ni = 1 THEN
d(i - 1) = z(i)
ELSE
d(i + 5) = z(i) + 6
END IF
NEXT

CALL titre
CALL cadre(4, 21, 36, 15, rouge)
LOCATE 6, , 0
COLOR blanc, rouge
h = 24
LOCATE , h: PRINT l1$
FOR i = 1 TO 5
LOCATE , h: PRINT l0$: LOCATE , h: PRINT l1$
NEXT
LOCATE , h: PRINT l0$: LOCATE , h: PRINT l4$

COLOR blancbrill, rouge
v = 7: h = 23
FOR i = 0 TO 5
IF ni = 1 THEN
LOCATE v, h: PRINT RTRIM$(STR$(n(i)))
ELSE
LOCATE v, (h + 1) - LEN(LTRIM$(STR$(n(i + 6)))): PRINT RTRIM$(STR$(n(i + 6)))
END IF
v = v + 2
NEXT

LOCATE 5, h: COLOR vertclair: PRINT " X"; : COLOR jaune
h = 24
FOR i = 0 TO 5
LOCATE , h + 3 + (i * 5)
IF ni = 1 THEN
PRINT d(i);
ELSE
PRINT d(i + 6);
END IF
NEXT

v = 7: h = 28: total = 1

ta2:
CALL niv(36, total)
souris = 0
x1 = (v - 7) / 2: y1 = (h - 28) / 5
IF ca(x1, y1) = 0 THEN
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

LOCATE , , 0
COLOR , noir
CALL centre(23, blanc, "Tape la réponse ou " + ff$)
LOCATE , , 1
DO
LOCATE v, h: nl = 3
GOSUB inpute
LOOP WHILE r$ = CHR$(13) AND souris = 0

IF souris = 2 THEN GOTO ta2

ELSE
COLOR , noir
LOCATE 23, 1, 0: PRINT SPACE$(80)
CALL centre(23, blanc, ff$)
LOCATE v, h, 1
COLOR blancbrill

DO
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
'ligne fleches et entree
IF v_mouse = 23 THEN
IF h_mouse = 37 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 39 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 41 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 43 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSEIF v_mouse = 7 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF
ELSEIF v_mouse = 9 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 11 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 13 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 15 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 17 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN GOTO ta2

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

IF rr = gauche OR rr = droite OR rr = haut OR rr = bas THEN
r$ = CHR$(rr)
EXIT DO
END IF
IF rr = 27 THEN
CALL quitter(noir, noir)
LOCATE v, h, 1
END IF
LOOP
END IF

SELECT CASE ASC(r$)

CASE gauche
h = h - 5
IF h < 28 THEN v = v - 2: h = 53
IF v < 7 THEN v = 17: BEEP
GOTO ta2

CASE droite
h = h + 5
IF h > 53 THEN v = v + 2: h = 28
IF v > 17 THEN v = 7: BEEP
GOTO ta2

CASE bas
v = v + 2
IF v > 17 THEN v = 7: BEEP
GOTO ta2

CASE haut
v = v - 2
IF v < 7 THEN v = 17: BEEP
GOTO ta2

END SELECT

r = VAL(r$)
IF ni = 1 THEN x = (v - 7) / 2: y = (h - 28) / 5
IF ni = 2 THEN x = ((v - 7) / 2) + 6: y = ((h - 28) / 5) + 6
COLOR , noir
IF r = n(x) * d(y) THEN
LOCATE 23, 1: PRINT SPACE$(80)
CALL exact2
ELSE
COLOR noir, rouge
LOCATE v, h - 1: PRINT " "
LOCATE v, h - 1: PRINT "="; LTRIM$(STR$(d(y) * n(x)))
COLOR blancbrill, noir: er = er + 1
END IF

x1 = (v - 7) / 2: y1 = (h - 28) / 5: ca(x1, y1) = 1

'test si fin
f = 0: total = 0
FOR i = 0 TO 5
FOR j = 0 TO 5
IF ca(i, j) = 0 THEN
f = 1
total = total + 1
END IF
NEXT j
NEXT i

total = 37 - total

IF f = 0 THEN
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL entree(noir, noir)
re = 10 - er: IF re < 0 THEN re = 0
CALL resultats(re, ni, 2)
EXIT SUB '+++++
END IF

DO
h = h + 5
IF h > 53 THEN v = v + 2: h = 28
IF v > 17 THEN v = 7
x1 = (v - 7) / 2: y1 = (h - 28) / 5
LOOP WHILE ca(x1, y1) = 1

GOTO ta2

'++++++++++++++++++++++

inpute:
COLOR , rouge
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

ligne = CSRLIN
colon = POS(0)
LOCATE ligne, colon: PRINT " "
LOCATE ligne, colon, 1, 0, 7

FOR ii = 1 TO nl + 1
ta5:
IF ii <= 0 THEN ii = 1
ta6:
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton AND ii > 1 THEN
BEEP
ELSEIF lButton THEN
'ligne fleches et entree
IF v_mouse = 23 THEN
IF h_mouse = 47 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 49 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 51 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 53 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF

ELSEIF v_mouse = 7 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF
ELSEIF v_mouse = 9 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 11 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 13 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 15 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

ELSEIF v_mouse = 17 THEN
IF h_mouse >= 27 AND h_mouse <= 30 THEN
v = v_mouse: h = 28
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 32 AND h_mouse <= 35 THEN
v = v_mouse: h = 33
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 37 AND h_mouse <= 40 THEN
v = v_mouse: h = 38
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 42 AND h_mouse <= 45 THEN
v = v_mouse: h = 43
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 47 AND h_mouse <= 50 THEN
v = v_mouse: h = 48
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 52 AND h_mouse <= 55 THEN
v = v_mouse: h = 53
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF

END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN
x1 = (v - 7) / 2: y1 = (h - 28) / 5
IF ca(x1, y1) = 0 THEN
LOCATE v, h, 1
GOTO inpute
ELSE
RETURN
END IF
END IF

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

re$(ii) = CHR$(rr)

IF rr = 27 THEN
CALL quitter(noir, bleu)
LOCATE v, h, 1
GOTO inpute
END IF

IF rr = 13 OR rr = droite THEN
EXIT FOR
END IF

IF (rr = gauche OR rr = droite OR rr = haut OR rr = bas) AND ii = 1 THEN
EXIT FOR
END IF

IF ii > 1 AND (rr = 8 OR rr = gauche OR rr = 83) THEN
PRINT CHR$(29); " "; CHR$(29);
ii = ii - 1
GOTO ta5
END IF

IF rr < 48 OR rr > 57 THEN
CALL chiffreslettres(noir, bleu, 1)
LOCATE v, h, 1
GOTO inpute
END IF

IF ii = nl + 1 THEN BEEP: GOTO ta6

PRINT re$(ii);
NEXT ii

PRINT : LOCATE , , 0
r$ = "": FOR jj = 1 TO ii - 1: r$ = r$ + re$(jj): NEXT
r$ = LTRIM$(r$): r$ = RTRIM$(r$)
IF r$ = "" THEN r$ = CHR$(rr)
COLOR , noir
RETURN

END SUB

DEFINT A-Z
SUB trouve (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'24/1/95 ok

a$ = "Tu dois chercher le nombre qui vient"
b$ = "entre les deux nombres affichés."
re = 0
ct = 0

'présentation
w$ = "L'ordinateur va choisir un nombre"
z$ = "au hasard."
y$ = "A toi de le trouver."
CALL consigne(3, w$, z$, y$)

'niveau
CALL Niveau(ni, 4)

FOR ii = 1 TO 3 '++++++++++++

CALL titre
MouseHide
CALL niv(3, ii)
SELECT CASE ni
CASE 1
dernier = 40: nl = 2
CASE 2
dernier = 70: nl = 2
CASE ELSE
dernier = 10 ^ ni: nl = ni
END SELECT

l2$ = SPACE$(80): hh = (80 / 2) + 1
premier = 0: cc = 0
max = dernier

'tirage
DO
ha = INT(RND * dernier)
LOOP WHILE rep = ha OR ha < 8
rep = ha

'début
DO
cc = cc + 1
IF ni < 3 THEN
CALL cadre(10, 33, 14, 4, rouge)
ELSE
CALL cadre(10, 30, 20, 4, rouge)
END IF

tr1:
'barregraph
IF ni = 1 OR ni = 2 THEN
dernier$ = LTRIM$(RTRIM$(STR$(dernier)))
premier$ = LTRIM$(RTRIM$(STR$(premier)))

COLOR blanc, bleu
LOCATE 17, 1: PRINT l2$
IF ni = 1 THEN
LOCATE 18, 20
ELSE
LOCATE 18, 5
END IF
PRINT "0├"; STRING$(max - 1, "."); "┤"; LTRIM$(RTRIM$(STR$(max)))

COLOR jaune
IF premier <> 0 THEN
IF premier < 10 THEN
IF ni = 1 THEN
LOCATE 17, 21 + premier: PRINT premier$
ELSE
LOCATE 17, 6 + premier: PRINT premier$
END IF
ELSE
IF ni = 1 THEN
LOCATE 17, 20 + premier: PRINT premier$
ELSE
LOCATE 17, 5 + premier: PRINT premier$
END IF
END IF
END IF
IF dernier <> max THEN
IF ni = 1 THEN
LOCATE 17, 21 + dernier: PRINT dernier$
ELSE
LOCATE 17, 6 + dernier: PRINT dernier$
END IF
END IF
esp = (max - 1) - (premier + (max - dernier))

COLOR blanc
IF ni = 1 THEN
LOCATE 18, 22
ELSE
LOCATE 18, 7
END IF

PRINT STRING$(premier, "▒") + STRING$(esp, ".") + STRING$(max - dernier, "▒")
END IF
'--------------------- fin barregraph

COLOR blanc, noir
h = LEN(STR$(premier) + STR$(dernier)) + 22

LOCATE 23, 1: PRINT l2$

LOCATE 23, hh - INT(h / 2)
PRINT "Tape un nombre entre"; : COLOR jaune: PRINT premier; : COLOR blanc: PRINT "et"; : COLOR jaune: PRINT dernier: COLOR blancbrill

ll = LEN(RTRIM$(LTRIM$(STR$(premier))) + RTRIM$(LTRIM$(STR$(dernier)))) + 6 + nl
h3 = LEN(RTRIM$(LTRIM$(STR$(premier)))) + 3
h = hh - INT(ll / 2)
COLOR , rouge
LOCATE 12, h: COLOR jaune: PRINT RTRIM$(LTRIM$(STR$(premier)));
COLOR vertclair: PRINT " < "; SPACE$(nl); " < ";
COLOR jaune: PRINT RTRIM$(LTRIM$(STR$(dernier)))
LOCATE 12, h + h3

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &h30) 'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG

CALL inputgen(nl, r$, 48, 57, rouge)

reponse& = VAL(r$)
COLOR , noir
LOCATE 23, 1: PRINT l2$

IF reponse& = rep THEN
LOCATE 12, h + h3 - 1
COLOR cyanclair, rouge: PRINT rep
IF ni < 3 THEN
rep$ = LTRIM$(STR$(rep))
COLOR cyanclair, bleu
IF rep <> 0 THEN
IF rep < 10 THEN
IF ni = 1 THEN
LOCATE 19, 21 + rep: PRINT rep$
ELSE
LOCATE 19, 6 + rep: PRINT rep$
END IF
ELSE
IF ni = 1 THEN
LOCATE 19, 20 + rep: PRINT rep$
ELSE
LOCATE 19, 5 + rep: PRINT rep$
END IF
END IF
END IF
END IF
COLOR , noir
EXIT DO
END IF

IF reponse& = premier OR reponse& = dernier THEN
CALL erreur2
GOTO tr1
END IF

IF reponse& > max THEN
CALL centre(23, rougeclair, "Maximum :" + STR$(max))
CALL attendre(1.5)
GOTO tr1
END IF

IF reponse& > dernier OR reponse& < premier THEN
IF ni > 2 THEN
CALL centre(22, rougeclair, a$)
CALL centre(23, rougeclair, b$)
ELSE
CALL centre(23, rougeclair, a$ + " " + b$)
END IF
CALL getinvimouse(w)
LOCATE 22, 1: PRINT l2$: PRINT l2$
GOTO tr1
END IF

IF reponse& < rep THEN
premier = reponse&
ELSE
dernier = reponse&
END IF

LOOP

CALL exact2

h = LEN(STR$(cc)) + 22
LOCATE 23, hh - INT(h / 2): COLOR jaune: PRINT "Tu as trouvé en" + STR$(cc);
PRINT " coup"; : IF cc > 1 THEN PRINT "s." ELSE PRINT "."

CALL getinvimouse(w)

ct = ct + cc
NEXT ii '+++++++++++++++

SELECT CASE ni
CASE 1
re = 28 - ct
CASE 2
re = 30 - ct
CASE 3
re = 40 - ct
CASE 4
re = 51 - ct
END SELECT

IF re > 10 THEN re = 10
IF re < 0 THEN re = 0

CALL resultats(re, ni, 4)

END SUB

DEFINT A-Z
SUB valeurchiffres (re%, ni%, ta1$(), ta$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'10/4/96
DIM z(10), zz(10)
re = 0
g$ = CHR$(27) + " " + CHR$(26) + " puis " + rt$
fh$ = CHR$(24)
CONST gauche = 75, droite = 77

'niveau
CALL Niveau(ni, 2)

nu = 0

IF ni = 1 THEN
GOSUB valniv1
ELSE
GOSUB valniv2
END IF

CALL resultats(re, ni, 2)

EXIT SUB

valniv1:
FOR ii = 1 TO 10 '+++++++++++
CALL titre
CALL niv(10, ii)

nr$ = ""
'les 5 premiers essais nombre xxx xxx
IF ii < 6 THEN
h = 44: maxi = h - 1: mini = maxi - 6
FOR i = 1 TO 7
n = (RND * 8) + 1
n$ = LTRIM$(STR$(n))
IF i = 4 THEN n$ = " "
nr$ = nr$ + n$
NEXT

CALL cadre(11, 31, 17, 4, rouge)
COLOR vertclair, rouge: LOCATE 13, 37: PRINT nr$

ELSE
'les 5 essais suivants nombre xxx xxx xxx
h = 46: maxi = h - 1: mini = maxi - 10
FOR i = 1 TO 11
n = (RND * 8) + 1
n$ = LTRIM$(STR$(n))
IF i = 4 OR i = 8 THEN n$ = " "
nr$ = nr$ + n$
NEXT

CALL cadre(11, 30, 20, 4, rouge)
COLOR vertclair, rouge: LOCATE 13, 35: PRINT nr$
END IF

IF ii = 10 THEN
nu = INT(RND * 9) + 1
ELSE
DO
f = 0
IF ii < 6 THEN
z(ii) = INT(RND * 6) + 4
ELSE
z(ii) = INT(RND * 9) + 1
END IF
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
nu = z(ii)
END IF

flag = 1
DO
CALL cadre(7, 15, 50, 2, marron)
COLOR , marron
CALL centre(8, blancbrill, "Indique le chiffre des " + ta1$(nu))

DO
COLOR blancbrill, rouge
LOCATE 14, 35: PRINT SPACE$(12)
LOCATE 14, h: PRINT fh$
COLOR , noir
CALL centre(23, blanc, g$)

DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
IF v_mouse = 13 OR v_mouse = 14 THEN
IF ii < 6 THEN
IF h_mouse = 37 OR h_mouse = 38 OR h_mouse = 39 OR h_mouse = 41 OR h_mouse = 42 OR h_mouse = 43 THEN
h = h_mouse
COLOR blancbrill, rouge
LOCATE 14, 35: PRINT SPACE$(12)
LOCATE 14, h: PRINT fh$
CALL attendre(.3)
flag = 0
souris = 2
EXIT DO
ELSE
BEEP
END IF
ELSE
IF h_mouse = 35 OR h_mouse = 36 OR h_mouse = 37 OR h_mouse = 39 OR h_mouse = 40 OR h_mouse = 41 OR h_mouse = 43 OR h_mouse = 44 OR h_mouse = 45 THEN
h = h_mouse
COLOR blancbrill, rouge
LOCATE 14, 35: PRINT SPACE$(12)
LOCATE 14, h: PRINT fh$
CALL attendre(.3)
flag = 0
souris = 2
EXIT DO
ELSE
BEEP
END IF
END IF
ELSEIF v_mouse = 23 THEN
IF h_mouse = 35 THEN
'fleche gauche
x = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche droite
x = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 44 AND h_mouse <= 46 THEN
'entree
x = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN EXIT DO

IF souris = 0 THEN
IF LEN(r$) < 2 THEN x = ASC(r$) ELSE x = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE x

CASE gauche
flag = 0
IF h > mini THEN h = h - 1
IF ii < 6 THEN
IF h = 40 THEN h = 39
ELSE
IF h = 42 THEN h = 41
IF h = 38 THEN h = 37
END IF

CASE droite
IF flag = 1 THEN
BEEP
ELSE
IF h < maxi THEN h = h + 1
IF ii < 6 THEN
IF h = 40 THEN h = 41
ELSE
IF h = 42 THEN h = 43
IF h = 38 THEN h = 39
END IF
END IF

CASE 27
CALL quitter(noir, noir)

CASE 13
IF flag = 1 THEN
BEEP
ELSE
EXIT DO
END IF

CASE ELSE
BEEP

END SELECT

LOOP

IF ii < 6 THEN
IF h = 43 THEN rep = 9
IF h = 42 THEN rep = 8
IF h = 41 THEN rep = 7

IF h = 39 THEN rep = 6
IF h = 38 THEN rep = 5
IF h = 37 THEN rep = 4

ELSE
IF h = 45 THEN rep = 9
IF h = 44 THEN rep = 8
IF h = 43 THEN rep = 7

IF h = 41 THEN rep = 6
IF h = 40 THEN rep = 5
IF h = 39 THEN rep = 4

IF h = 37 THEN rep = 3
IF h = 36 THEN rep = 2
IF h = 35 THEN rep = 1
END IF

COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF rep = nu THEN
IF cc = 0 THEN re = re + 1
cc = 0
CALL exact2
EXIT DO

ELSE
CALL centre(23, rougeclair, "Tu as montré le chiffre des " + ta1$(rep))
CALL attendre(2)
LOCATE 23, 1: PRINT SPACE$(80)
cc = cc + 1
END IF

LOOP
NEXT ii '++++++++++
RETURN

valniv2:
FOR ii = 1 TO 10 '+++++++++++++
CALL titre
CALL niv(10, ii)

DO
f = 0
zz(ii) = INT(RND * 10) + 1
FOR j = 1 TO ii - 1
IF zz(ii) = zz(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
w = zz(ii)

SELECT CASE w
CASE 1
nr$ = "41942,584"
CASE 2
nr$ = "79430,187"
CASE 3
nr$ = "92543,882"
CASE 4
nr$ = "17326,708"
CASE 5
nr$ = "60437,062"
CASE 6
nr$ = "49943,192"
CASE 7
nr$ = "66500,238"
CASE 8
nr$ = "90431,117"
CASE 9
nr$ = "74896,004"
CASE 10
nr$ = "70054,106"
END SELECT

CALL cadre(11, 30, 20, 4, rouge)
COLOR vertclair, rouge: LOCATE 13, 36: PRINT nr$

IF ii < 9 THEN
DO
f = 0
z(ii) = INT(RND * 8) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
nu = z(ii)
ELSE
nu = INT(RND * 8) + 1
END IF

h = 41

flag = 1
DO

CALL cadre(7, 15, 50, 2, marron)
COLOR , marron
CALL centre(8, blancbrill, "Indique le chiffre des " + ta$(nu))

DO
COLOR blancbrill, rouge
LOCATE 14, 34: PRINT SPACE$(11)
LOCATE 14, h: PRINT fh$
COLOR , noir
CALL centre(23, blanc, g$)

DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
IF v_mouse = 13 OR v_mouse = 14 THEN
IF (h_mouse >= 36 AND h_mouse <= 40) OR (h_mouse >= 42 AND h_mouse <= 44) THEN
h = h_mouse
COLOR blancbrill, rouge
LOCATE 14, 35: PRINT SPACE$(12)
LOCATE 14, h: PRINT fh$
CALL attendre(.3)
flag = 0
souris = 2
EXIT DO
ELSE
BEEP
END IF
ELSEIF v_mouse = 23 THEN
IF h_mouse = 35 THEN
'fleche gauche
x = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche droite
x = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 44 AND h_mouse <= 46 THEN
'entree
x = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN EXIT DO

IF souris = 0 THEN
IF LEN(r$) < 2 THEN x = ASC(r$) ELSE x = ASC(RIGHT$(r$, 1))
END IF


SELECT CASE x

CASE gauche
flag = 0
IF h > 36 THEN h = h - 1: IF h = 41 THEN h = 40

CASE droite
flag = 0
IF h < 44 THEN h = h + 1: IF h = 41 THEN h = 42

CASE 27
CALL quitter(noir, noir)

CASE 13
IF flag = 1 THEN
BEEP
ELSE
EXIT DO
END IF

CASE ELSE
BEEP

END SELECT
LOOP

rep = h - 35: IF rep > 6 THEN rep = rep - 1

COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF rep = nu THEN
IF cc = 0 THEN re = re + 1
cc = 0
CALL exact2
EXIT DO

ELSE
CALL centre(23, rougeclair, "Tu as montré le chiffre des " + ta$(rep))
CALL attendre(2)
LOCATE 23, 1: PRINT SPACE$(80)
cc = cc + 1
END IF

LOOP

NEXT ii '+++++++++++++
RETURN

END SUB
 

 

DECLARE SUB niv (limit%, xx%)
DECLARE SUB attendre (tx!)
DECLARE SUB centre (v%, coul%, ph$)
DECLARE SUB chiffreslettres (x%, y%, t%)
DECLARE SUB convertir (z$)
DECLARE SUB convertir2 (no$)
DECLARE SUB entree (y%, z%)
DECLARE SUB erreur2 ()
DECLARE SUB exact2 ()
DECLARE SUB inputgen (nl%, r$, deb%, fin%, fond%)
DECLARE SUB ligne23 (x%, y%, z!)
DECLARE SUB Niveau (ni%, np%)
DECLARE SUB quitter (x%, y%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB titre ()
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB aidefois (titr$, ni%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB correction (donnee$)
DECLARE SUB fois (re%, ni%, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB foisdeux (re%, ni%, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB multi2 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB multi (res$, a&, b&, cc%, v%, h%, no%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, coul%)
DECLARE SUB MouseHide ()
DECLARE SUB MousePoll (row%, col%, lButton%, rButton%)
'EXERCICES 4 MATH COLLEGE
'5/5/96
'Daniel CLERC
'version 1.0


DEFINT A-Z
SUB aidefois (titr$, ni, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'26/12/94
COLOR , bleu: CLS
LOCATE 2, 3: COLOR jaune: PRINT "Rappel"
CALL cadre(3, 2, 75, 17, rouge)
COLOR , rouge
temp$ = "Multiplication par "
LOCATE 7: h = 9
COLOR jaune
LOCATE , h: PRINT temp$; "10 : les unités deviennent dizaines."
PRINT
COLOR blancbrill
LOCATE , h + 26: PRINT "53"; : COLOR vertclair: PRINT "4"; : COLOR blancbrill: PRINT " x 10 = 53"; : COLOR vertclair: PRINT "4"; : COLOR blancbrill: PRINT "0"
PRINT
COLOR jaune
LOCATE , h: PRINT temp$; "100 : les unités deviennent centaines."
PRINT
COLOR blancbrill
LOCATE , h + 26: PRINT "12"; : COLOR vertclair: PRINT "7"; : COLOR blancbrill: PRINT " x 100 = 12"; : COLOR vertclair: PRINT "7"; : COLOR blancbrill: PRINT "00"
PRINT
COLOR jaune
LOCATE , h: PRINT temp$; "1000 : les unités deviennent unités de mille."
PRINT
COLOR blancbrill
LOCATE , h + 26: PRINT "84"; : COLOR vertclair: PRINT "2"; : COLOR blancbrill: PRINT " x 1000 = 84"; : COLOR vertclair: PRINT "2"; : COLOR blancbrill: PRINT "000"
CALL entree(bleu, bleu)

IF ni = 1 OR ni = 2 THEN EXIT SUB

CALL cadre(3, 2, 75, 17, rouge)
COLOR , rouge

temp$ = "Division par "
LOCATE 7: h = 13
COLOR jaune
LOCATE , h: PRINT temp$; "10 : les unités deviennent dixièmes."
PRINT
COLOR blancbrill
LOCATE , h + 26: PRINT "53"; : COLOR vertclair: PRINT "4"; : COLOR blancbrill: PRINT " : 10 = 53,"; : COLOR vertclair: PRINT "4"
PRINT
COLOR jaune
LOCATE , h: PRINT temp$; "100 : les unités deviennent centièmes."
PRINT
COLOR blancbrill
LOCATE , h + 26: PRINT "12"; : COLOR vertclair: PRINT "7"; : COLOR blancbrill: PRINT " : 100 = 1,2"; : COLOR vertclair: PRINT "7"
PRINT
COLOR jaune
LOCATE , h: PRINT temp$; "1000 : les unités deviennent millièmes."
PRINT
COLOR blancbrill
LOCATE , h + 26: PRINT "84"; : COLOR vertclair: PRINT "2"; : COLOR blancbrill: PRINT " : 1000 = 0,84"; : COLOR vertclair: PRINT "2"
CALL entree(bleu, bleu)

END SUB

DEFINT A-Z
SUB choixfois (re, ni, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'6/2/95
'niveau
CALL Niveau(ni, 4)

CLS
SELECT CASE ni
CASE 1, 3
CALL aidefois(titr$, ni, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
CALL fois(re, ni, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
CASE 2, 4
CALL aidefois(titr$, ni, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
CALL foisdeux(re, ni, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
END SELECT

'résultats
CALL resultats(re, ni, 4)

END SUB

DEFINT A-Z
SUB choixmulti (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'27/3/95
'niveau
CALL Niveau(ni, 4)
COLOR , noir

SELECT CASE ni
CASE 1
CALL multi2(re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

CASE 2, 3, 4
'27/3/95 pour niveau 2, 3 et 4
DIM res$(4)

re = 0: cc = 0
IF ni = 2 THEN
m2 = 2
ELSE
m2 = 3
END IF

FOR no = 1 TO 5 '++++++++++++
CALL titre
CALL niv(5, no)

'tirage
DO
IF ni = 2 OR ni = 3 THEN
a& = INT(RND * 800) + 157 '3 chiffres
ELSE
a& = INT(RND * 1500) + 2000 '4 chiffres
END IF
la = LEN(LTRIM$(STR$(a&)))
a$ = LTRIM$(STR$(a&))

DO
b& = INT(RND * (10 ^ m2)) '2 ou 3 chiffres suivant niveau
lb = LEN(LTRIM$(STR$(b&)))
b$ = LTRIM$(STR$(b&))
LOOP WHILE lb <> m2

f = 0
FOR i = 1 TO lb
IF MID$(b$, i, 1) = "0" THEN f = 1: EXIT FOR
NEXT

LOOP WHILE a& < b& OR f = 1

CALL cadre(7, 25, 30, 9 + lb, rouge)
COLOR , rouge
CALL multi(reponse$, a&, b&, cc%, 9, 45, no%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, rouge)

COLOR , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
COLOR rougeclair
LOCATE 23, 32
PRINT "Tu as fait"; cc; "faute"; : IF cc > 1 THEN PRINT "s";
PRINT "."
END IF
CALL getinvimouse(w)
cc = 0
NEXT no '+++++++++++

END SELECT

'résultats
CALL resultats(re, ni, 3)

END SUB

DEFINT A-Z
SUB correction (donnee$)
'7/2/95
'problème quand puissance D-02 ET E ===

donnee$ = LTRIM$(RTRIM$(donnee$))
donnee! = VAL(donnee$)
donnee2! = donnee!

l = LEN(donnee$)

'on teste s'il y des décimales
s = INSTR(1, donnee$, ".")
IF s = 0 THEN
EXIT SUB 'pas de décimale
END IF

'on teste les puissances
r = INSTR(1, donnee$, "E-")

IF r = 0 THEN

l2 = l - s 'calcul des décimales

IF RIGHT$(donnee$, 1) = "9" THEN
f = 0
DO
IF LEN(STR$(donnee!)) = LEN(STR$(donnee2!)) THEN
donnee2! = donnee! + (10 ^ -l2) + ((10 ^ -(l2 + 1)) * f)
f = f + 1
ELSE
EXIT DO
END IF
LOOP

donnee$ = LTRIM$(RTRIM$(STR$(donnee2!)))

ELSEIF RIGHT$(donnee$, 1) = "1" THEN
f = 0
DO
IF LEN(STR$(donnee!)) = LEN(STR$(donnee2!)) THEN
donnee2! = donnee! - (10 ^ -l2) - ((10 ^ -(l2 + 1)) * f)
f = f + 1
ELSE
EXIT DO
END IF
LOOP

donnee$ = LTRIM$(RTRIM$(STR$(donnee2!)))
END IF

ELSE
'il faut traiter le problème des puissances ===
'STOP '===
END IF

END SUB

DEFINT A-Y
SUB fois (re, ni, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'5/5/96 'niveau 1 & 3
'au niveau 1 rien que des multiplications en nombres entiers
'au niveau 3 multi et divi : les 5 premiers en entiers, les autres en décimaux

CONST gauche = 75, droite = 77, haut = 72, bas = 80

DIM y(10)

re = 0
oper = 2
gg2$ = CHR$(27) + " " + CHR$(26) + " puis " + rt$
IF ni = 1 THEN
l6$ = "┌───────────┬───────────┐"

l0$ = "│ │ │"

l3$ = "├───┼───┼───┼───┼───┼───┤"

l4$ = "│ │ │ │ │ │ │"

l5$ = "└───┴───┴───┴───┴───┴───┘"

ELSEIF ni = 3 THEN

l6$ = "┌───────────┬───────────┬───────────────┐"

l0$ = "│ │ │ │"

l3$ = "├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤"

l4$ = "│ │ │ │ │ │ ║ │ │ │ │"

l5$ = "└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘"

END IF

CALL titre

FOR ii = 1 TO 10 '++++++++++++++++++++
flag = 0
GOSUB tirage

CALL niv(10, ii)
LOCATE 6, 1: PRINT SPACE$(80)
CALL centre(6, jaune, oper$ + STR$(10 ^ puis))

'boucle saisie
er = 0
COLOR , noir
GOSUB tableau
IF ni = 3 THEN LOCATE 16, 7 ELSE LOCATE 16, 17
PRINT SPACE$(11)

fois1:
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, gg2$)

DO
no2$ = no$: CALL convertir2(no2$): zz = VAL(no2$): no2$ = STR$(zz)

no$ = STR$(z * 10 ^ flag)

'test si pas erreur en SNG ===
s = INSTR(1, no$, ".")
IF s <> 0 THEN
ll = LEN(no2$)
l = LEN(no$)
IF ABS(l - ll) > 1 THEN CALL correction(no$)
END IF

CALL convertir(no$)
COLOR , noir
'moitié de tableau
IF ni = 3 THEN h = 20 ELSE h = 30
COLOR jaune: LOCATE 15
FOR i = 1 TO 2: LOCATE , h: PRINT l4$: NEXT
LOCATE , h: PRINT l5$

COLOR vertclair
IF ni = 3 THEN LOCATE 16, 7 ELSE LOCATE 16, 17
IF LEFT$(oper$, 1) = "M" THEN
PRINT " x";
ELSE
PRINT " :";
END IF

PRINT STR$(10 ^ puis); " "; CHR$(26)

LOCATE 14
z0$ = zori$
GOSUB affiche

LOCATE 16
z0$ = no$
GOSUB affiche2

DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
IF v_mouse = 23 THEN
IF h_mouse = 35 THEN
'fleche gauche
r = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche droite
r = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 44 AND h_mouse <= 46 THEN
'entree
r = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 0 THEN
IF LEN(r$) < 2 THEN r = ASC(r$) ELSE r = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE r

CASE 13
EXIT DO

CASE gauche
flag = flag + 1
IF flag > max2 THEN
flag = max2
BEEP
ELSE
h3 = h3 - 1
END IF

CASE droite
flag = flag - 1
IF flag < max THEN
flag = max
BEEP
ELSE
h3 = h3 + 1
END IF

CASE 27
CALL quitter(noir, noir)

END SELECT

LOOP

COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF flag = flag2 THEN
CALL exact2: IF er = 0 THEN re = re + 1
ELSE
er = er + 1
IF puis <> 0 THEN
z$ = "Les unités deviennent "
IF LEFT$(oper$, 1) = "M" THEN
z$ = z$ + fois1$(puis)
ELSE
z$ = z$ + fois2$(puis)
END IF

IF flag >= 0 THEN
w$ = "Tu as multiplié par"
ELSE
w$ = "Tu as divisé par"
END IF

BEEP
CALL centre(23, rougeclair, w$ + STR$(10 ^ ABS(flag)))
CALL attendre(2)
CALL centre(23, jaune, z$)
CALL getinvimouse(w)
ELSE
'x 1
IF flag >= 0 THEN
w$ = "Tu as multiplié par"
ELSE
w$ = "Tu as divisé par"
END IF

BEEP
CALL centre(23, rougeclair, w$ + STR$(10 ^ ABS(flag)))
CALL attendre(2)
CALL centre(23, jaune, "Les unités restent unités")
CALL getinvimouse(w)
END IF
GOTO fois1
END IF

NEXT ii '+++++++++++++++++

EXIT SUB

tableau:
IF ni = 3 THEN h = 20 ELSE h = 30
v = 9
COLOR jaune
LOCATE v, h: PRINT l6$
LOCATE , h: PRINT l0$
LOCATE , h: PRINT l0$
LOCATE , h: PRINT l3$
FOR i = 1 TO 4: LOCATE , h: PRINT l4$: NEXT
LOCATE , h: PRINT l5$

COLOR blancbrill
LOCATE v + 1, h + 4: PRINT "Mille";
LOCATE , h + 16: PRINT "U. S.";

IF ni = 3 THEN
LOCATE , h + 28: PRINT "Décimales"
ELSE
PRINT
END IF

COLOR vertclair
LOCATE v + 2
LOCATE , h + 2: PRINT "c";
LOCATE , h + 6: PRINT "d";
LOCATE , h + 10: PRINT "u";
LOCATE , h + 14: PRINT "c";
LOCATE , h + 18: PRINT "d";
LOCATE , h + 22: PRINT "u";
IF ni = 3 THEN
COLOR rougeclair
LOCATE , h + 26: PRINT "d";
LOCATE , h + 30: PRINT "c";
LOCATE , h + 34: PRINT "m";
LOCATE , h + 37: PRINT "d m"
END IF
RETURN

affiche:
vir = INSTR(z0$, ",")
IF ni = 3 THEN h1 = 42 ELSE h1 = 52
IF vir = 0 THEN
'pas de virgule
FOR i = LEN(z0$) TO 1 STEP -1
LOCATE , h1
IF i = LEN(z0$) THEN COLOR jaune ELSE COLOR blancbrill
PRINT MID$(z0$, i, 1);
h1 = h1 - 4
NEXT

ELSE
'virgule
z1$ = MID$(z0$, 1, vir - 1)
z2$ = MID$(z0$, vir + 1, LEN(z0$) - (LEN(z1$) + 1))
FOR i = LEN(z1$) TO 1 STEP -1
LOCATE , h1
IF i = LEN(z1$) THEN COLOR jaune ELSE COLOR blancbrill
PRINT MID$(z1$, i, 1);
h1 = h1 - 4
NEXT

h1 = 46
COLOR blancbrill: LOCATE , h1 - 3: PRINT ",";
FOR i = 1 TO LEN(z2$)
LOCATE , h1
PRINT MID$(z2$, i, 1);
h1 = h1 + 4
NEXT
END IF

RETURN

affiche2:
ll2 = INSTR(zori$, ",")
IF ll2 = 0 THEN
ll = LEN(zori$)
ELSE
ll = ll2 - 1
END IF

vir = INSTR(z0$, ",")
IF ni = 3 THEN h1 = 42 ELSE h1 = 52
IF vir = 0 THEN
'pas de virgule
FOR i = LEN(z0$) TO 1 STEP -1
LOCATE , h1
IF i = ll THEN COLOR jaune ELSE COLOR blancbrill
PRINT MID$(z0$, i, 1);
h1 = h1 - 4
NEXT

ELSE
'virgule
z1$ = MID$(z0$, 1, vir - 1)
z2$ = MID$(z0$, vir + 1, LEN(z0$) - (LEN(z1$) + 1))
FOR i = LEN(z1$) TO 1 STEP -1
LOCATE , h1
IF ll2 > 0 THEN
'IF i = LEN(z1$) THEN COLOR jaune ELSE COLOR blancbrill
IF i = ll THEN COLOR jaune ELSE COLOR blancbrill
END IF
PRINT MID$(z1$, i, 1);
h1 = h1 - 4
NEXT

h1 = 46
COLOR blancbrill: LOCATE , h1 - 3: PRINT ",";
FOR i = 1 TO LEN(z2$)
LOCATE , h1
IF ll2 = 0 THEN
IF i = LEN(z2$) THEN COLOR jaune ELSE COLOR blancbrill
ELSEIF LEFT$(z0$, 1) <> "0" THEN
IF i = ll - LEN(z1$) THEN COLOR jaune ELSE COLOR blancbrill
ELSE
IF i = (ll + 1) - LEN(z1$) THEN COLOR jaune ELSE COLOR blancbrill
END IF
PRINT MID$(z2$, i, 1);
h1 = h1 + 4
NEXT
END IF

RETURN

tirage:
'tirage si x ou : et combien au ni = 3
'tenir compte de max (valeur inférieure) max2 (valeur supérieure)
'au ni = 1 max = 1
'au ni = 3 :
'entiers : max = -3
'décimaux : si alea = 1 (2 décimales) alors max = -2 sinon max =-3

alea = 0
SELECT CASE ni

CASE 1
DO
z = INT(RND * 1000)
LOOP WHILE z < 35 OR RIGHT$(STR$(z), 1) = "0"
oper = 1

CASE 3
IF ii < 6 THEN
'nombre entier
DO
z = INT(RND * 1000)
LOOP WHILE z < 35 OR RIGHT$(STR$(z), 1) = "0"

ELSE
'nombre décimal
DO
alea = (RND * 2) + 1
SELECT CASE alea
CASE 1
z = INT(RND * 100000) / 100
CASE 2
z = INT(RND * 10000) / 10
END SELECT
LOOP WHILE z < 10 OR RIGHT$(STR$(z), 1) = "0"
END IF

IF oper = 1 THEN
oper = 2
ELSE
oper = 1
END IF

END SELECT

no$ = STR$(z)
CALL convertir(no$)
zori$ = no$

SELECT CASE ni
CASE 1
max = 0
CASE 3
IF ii < 6 THEN
max = -3
ELSEIF alea = 2 THEN
max = -3
ELSE
max = -2
END IF
END SELECT

IF z < 100 THEN
max2 = 4
ELSE
max2 = 3
END IF

SELECT CASE oper

CASE 1
oper$ = "Multiplication par"
DO
y(ii) = INT(RND * (max2 + 1))
LOOP WHILE y(ii) = puis
puis = y(ii)
flag2 = puis

CASE 2
oper$ = "Division par"
DO
y(ii) = INT(RND * (ABS(max) + 1))
LOOP WHILE y(ii) = puis OR y(ii) = 0
puis = y(ii)
flag2 = puis * -1
END SELECT

RETURN

END SUB

DEFINT A-Y
SUB foisdeux (re, ni, fois1$(), fois2$(), rt$, gg$, pre$, titr$, prog, noir, bleu, vert, rouge, marron, blanc, vertclair, cyanclair, rougeclair, jaune, blancbrill)
'11/4/96 niveau 2 et 4
'seulement multi au niveau 2
'entier POUR LES DIVISIONS
DIM y(10)

oper = 2
re = 0

'1° boucle : trouver l'opérande
FOR ii = 1 TO 5 '++++++++++++++++++
CALL titre
MouseHide

GOSUB tirage2

reponse$ = STR$(z * 10 ^ flag2)
CALL convertir(reponse$)

'test si pas erreur SNG et correction ===
no2$ = no$
s = INSTR(1, no2$, ",")
IF s <> 0 THEN no2$ = MID$(no2$, 1, s - 1) + MID$(no2$, s + 1)
reponse2$ = reponse$
s = INSTR(1, reponse2$, ",")
IF s <> 0 THEN reponse2$ = MID$(reponse2$, 1, s - 1) + MID$(reponse2$, s + 1)
IF RIGHT$(no2$, 1) <> RIGHT$(reponse2$, 1) THEN
CALL convertir2(reponse$)
CALL correction(reponse$)
CALL convertir(reponse$)
END IF

er = 0

CALL cadre(10, 28, 24, 4, blanc)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")

'boucle saisie
DO

CALL niv(10, ii)
COLOR noir, blanc

w$ = ""
w$ = no$
IF LEFT$(oper$, 1) = "M" THEN
w$ = w$ + " x"
ELSE
w$ = w$ + " :"
END IF

w$ = w$ + MID$(SPACE$(40), 1, LEN(STR$(10 ^ puis)) + 1) + " = " + reponse$
hh = INT(41 - (LEN(w$) / 2))
hh3 = hh + (LEN(w$) - LEN(reponse$))
CALL centre(12, noir, w$)
COLOR , noir
LOCATE 12, INT(41 - (LEN(w$) / 2)) + LEN(no$) + 3

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &h30) 'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG

CALL inputgen(LEN(STR$(10 ^ puis)) + 1, r$, 44, 59, blanc)
r& = VAL(r$): r2 = 10 ^ puis

COLOR , noir: LOCATE 23, 1: PRINT SPACE$(80)

IF r& = r2 THEN
CALL exact2: IF er = 0 THEN re = re + 1
EXIT DO
ELSEIF r& <> 10 AND r& <> 100 AND r& <> 1000 THEN
CALL centre(23, rougeclair, "10, 100 ou 1000...")
CALL attendre(2)
ELSE
er = er + 1
IF er > 2 THEN
CALL centre(23, rougeclair, "Solution :" + STR$(10 ^ puis))
CALL attendre(1)
ELSE
CALL erreur2
z$ = "Les unités sont devenues "
IF LEFT$(oper$, 1) = "M" THEN
z$ = z$ + fois1$(puis)
ELSE
z$ = z$ + fois2$(puis)
END IF
CALL centre(23, rougeclair, z$)
'mise en place des flèches et localisation unités
COLOR rouge, blanc
vir = INSTR(no$, ",")
IF vir = 0 THEN
LOCATE 12, hh + (LEN(no$) - 1): PRINT RIGHT$(no$, 1)
LOCATE 13, hh + (LEN(no$) - 1): PRINT CHR$(24)
'calculer l'emplacement de l'unité
vir2 = INSTR(reponse$, ",")
IF vir2 = 0 THEN
LOCATE 12, hh3 + (LEN(no$) - 1): PRINT RIGHT$(no$, 1)
LOCATE 13, hh3 + (LEN(no$) - 1): PRINT CHR$(24)
ELSE
IF LEFT$(reponse$, 2) = "0," THEN
LOCATE 12, hh3 + (LEN(reponse$) - 1): PRINT RIGHT$(no$, 1)
LOCATE 13, hh3 + (LEN(reponse$) - 1): PRINT CHR$(24)
ELSE
LOCATE 12, hh3 + (LEN(no$)): PRINT RIGHT$(no$, 1)
LOCATE 13, hh3 + (LEN(no$)): PRINT CHR$(24)
END IF
END IF
ELSE
LOCATE 12, hh + (vir - 2): PRINT MID$(no$, vir - 1, 1)
LOCATE 13, hh + (vir - 2): PRINT CHR$(24)
vir2 = INSTR(reponse$, ",")
IF vir2 = 0 THEN
LOCATE 12, hh3 + (vir - 2): PRINT MID$(no$, vir - 1, 1)
LOCATE 13, hh3 + (vir - 2): PRINT CHR$(24)
ELSEIF vir2 > vir THEN
LOCATE 12, hh3 + (vir - 2): PRINT MID$(no$, vir - 1, 1)
LOCATE 13, hh3 + (vir - 2): PRINT CHR$(24)
ELSE
IF LEFT$(reponse$, 3) = "0,0" THEN
LOCATE 12, hh3 + (vir + 1): PRINT MID$(no$, vir - 1, 1)
LOCATE 13, hh3 + (vir + 1): PRINT CHR$(24)
ELSEIF LEFT$(reponse$, 2) = "0," THEN
LOCATE 12, hh3 + vir: PRINT MID$(no$, vir - 1, 1)
LOCATE 13, hh3 + vir: PRINT CHR$(24)
ELSE
LOCATE 12, hh3 + (vir - 1): PRINT MID$(no$, vir - 1, 1)
LOCATE 13, hh3 + (vir - 1): PRINT CHR$(24)
END IF
END IF
END IF
CALL attendre(1.5)
END IF
END IF
LOOP

NEXT ii '++++++++++++++

'2° boucle
FOR ii = 6 TO 10 '++++++++++++++++++
CALL titre

GOSUB tirage2

CALL cadre(6, 28, 24, 2, vert)
COLOR , vert
CALL centre(7, blancbrill, oper$ + STR$(10 ^ puis))

reponse$ = STR$(z * 10 ^ flag2)
CALL convertir(reponse$)

'test si pas erreur SNG et correction ===
no2$ = no$
s = INSTR(1, no2$, ",")
IF s <> 0 THEN no2$ = MID$(no2$, 1, s - 1) + MID$(no2$, s + 1)
reponse2$ = reponse$
s = INSTR(1, reponse2$, ",")
IF s <> 0 THEN reponse2$ = MID$(reponse2$, 1, s - 1) + MID$(reponse2$, s + 1)
IF RIGHT$(no2$, 1) <> RIGHT$(reponse2$, 1) THEN
CALL convertir2(reponse$)
CALL correction(reponse$)
CALL convertir(reponse$)
END IF

er = 0

CALL cadre(10, 28, 24, 4, blanc)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, "Tape la réponse")

'boucle saisie
DO

CALL niv(10, ii)

w$ = ""
w$ = no$
IF LEFT$(oper$, 1) = "M" THEN
w$ = w$ + " x"
ELSE
w$ = w$ + " :"
END IF
w$ = w$ + STR$(10 ^ puis) + " = "

fois40:
COLOR , blanc
CALL centre(12, noir, w$ + SPACE$(6))
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &h30) 'numérique
POKE &H417, (PEEK(&H417) OR &H40) 'MAJ
DEF SEG

'COLOR noir, blanc
hh = INT(41 - (LEN(w$) + 6) / 2)
hh3 = hh + LEN(w$)

LOCATE 12, hh3
CALL inputgen(6, r$, 44, 59, blanc)
CALL convertir2(r$)
reponse2$ = reponse$: CALL convertir2(reponse2$)

'ôter les virgules, ôter les 0 à gauche puis comparer les 3 premiers chiffres
z$ = r$
s = INSTR(1, z$, ".")
IF s <> 0 THEN z$ = MID$(z$, 1, s - 1) + MID$(z$, s + 1)
z2$ = reponse2$
s = INSTR(1, z2$, ".")
IF s <> 0 THEN z2$ = MID$(z2$, 1, s - 1) + MID$(z2$, s + 1)
FOR i = 1 TO 2
IF MID$(z$, i, 1) <> "0" THEN
EXIT FOR
ELSEIF MID$(z$, i, 1) = "0" THEN
z$ = MID$(z$, i + 1)
END IF
NEXT
FOR i = 1 TO 2
IF MID$(z2$, i, 1) <> "0" THEN
EXIT FOR
ELSEIF MID$(z2$, i, 1) = "0" THEN
z2$ = MID$(z2$, i + 1)
END IF
NEXT

IF LEN(z$) < LEN(z2$) THEN l = LEN(z$) ELSE l = LEN(z2$)
IF l > 4 THEN l = 4
f = 0
FOR i = 1 TO l
IF MID$(z$, i, 1) <> MID$(z2$, i, 1) THEN
f = 1
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80): BEEP
CALL centre(23, rougeclair, "Les chiffres ne changent pas")
CALL attendre(2)
LOCATE 23, 1: PRINT SPACE$(80)
EXIT FOR
END IF
NEXT
IF f = 1 THEN GOTO fois40

r! = VAL(r$): reponse! = VAL(reponse2$)

COLOR , noir: LOCATE 23, 1: PRINT SPACE$(80)

IF r! = reponse! THEN
CALL exact2: IF er = 0 THEN re = re + 1
EXIT DO
ELSE
er = er + 1
IF er > 2 THEN
CALL centre(23, rougeclair, "Solution : " + reponse$)
CALL attendre(1)
ELSE
CALL erreur2
z$ = "Les unités deviennent "
IF LEFT$(oper$, 1) = "M" THEN
z$ = z$ + fois1$(puis)
ELSE
z$ = z$ + fois2$(puis)
END IF
CALL centre(23, rougeclair, z$)
'mise en place des flèches et localisation unités
COLOR rouge, blanc
vir = INSTR(no$, ",")
IF vir = 0 THEN
LOCATE 12, hh + (LEN(no$) - 1): PRINT RIGHT$(no$, 1)
LOCATE 13, hh + (LEN(no$) - 1): PRINT CHR$(24)
ELSE
LOCATE 12, hh + (vir - 2): PRINT MID$(no$, vir - 1, 1)
LOCATE 13, hh + (vir - 2): PRINT CHR$(24)
END IF
CALL attendre(1.5)
END IF
END IF
LOOP

NEXT ii '++++++++++++++


EXIT SUB

tirage2:
'tirage x (oper = 1) ou : (oper =2)
SELECT CASE ni
CASE 2
oper = 1
CASE 4
IF oper = 1 THEN
oper = 2
ELSE
oper = 1
END IF
END SELECT

'tirage nombre en fonction de ni et oper
SELECT CASE ni
CASE 2
DO
z = INT(RND * 1000)
LOOP WHILE z < 35 OR RIGHT$(STR$(z), 1) = "0"

CASE 4
IF oper = 2 THEN
'nombre entier
DO
z = INT(RND * 1000)
LOOP WHILE z < 35 OR RIGHT$(STR$(z), 1) = "0"

ELSE
DO
alea = (RND * 2) + 1
SELECT CASE alea
CASE 2
z = INT(RND * 10000) / 100
CASE 1
z = INT(RND * 1000) / 10
END SELECT
LOOP WHILE z < 10 OR RIGHT$(STR$(z), 1) = "0"
END IF
END SELECT

no$ = STR$(z)
CALL convertir(no$)

'tirage valeur opérateur
SELECT CASE oper

CASE 1
oper$ = "Multiplication par"
DO
y(ii) = INT(RND * 3) + 1
LOOP WHILE y(ii) = puis

puis = y(ii)
flag2 = puis

CASE 2
oper$ = "Division par"
DO
y(ii) = INT(RND * 2) + 1
LOOP WHILE y(ii) = puis
puis = y(ii)
flag2 = puis * -1
END SELECT

RETURN

END SUB

DEFINT A-Z
SUB multi2 (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'11/4/96 niveau 1
ll$ = STRING$(10, 196)

re = 0: cc = 0: f = 0

FOR no = 1 TO 5 '+++++++++++++
CALL titre
MouseHide
CALL niv(5, no)
'tirage

a = INT(RND * 40) + 150
b = INT(RND * 5) + 4 '8 maxi

a$ = LTRIM$(STR$(a))
b$ = LTRIM$(STR$(b))

la = LEN(LTRIM$(STR$(a)))
lb = LEN(LTRIM$(STR$(b)))
res$ = LTRIM$(STR$(b * a))

CALL cadre(7, 25, 30, b + 5, rouge)
COLOR , rouge

flag = 1
GOSUB multiaddposee
v = CSRLIN - 3
GOSUB multiposee
CALL attendre(1)

h = 0: zz = 0: retenue = 0: flag = 0

FOR boucle = LEN(res$) TO 1 STEP -1 '++++++++++

GOSUB multiaddposee
v = CSRLIN - 3
GOSUB multiposee
v = CSRLIN

retenue1 = INT(((VAL(MID$(STR$(a), LEN(STR$(a)) - zz, 1)) * b) + retenue) / 10)
retenue = retenue1

IF retenue1 <> 0 THEN
ret = 1
ELSE
ret = 0
END IF

multipli1:
COLOR , noir
CALL centre(23, blanc, "Tape la réponse")
COLOR blancbrill, rouge
LOCATE v, 36 - h: PRINT "_"
LOCATE v, 48 - h: PRINT "_"

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

re$ = INPUT$(1)
IF ASC(re$) = 27 THEN CALL quitter(noir, rouge): GOTO multipli1
IF ASC(re$) < 48 OR ASC(re$) > 57 THEN CALL chiffreslettres(noir, rouge, 1): GOTO multipli1
LOCATE v, 36 - h: PRINT re$
LOCATE v, 48 - h: PRINT re$

CALL ligne23(noir, noir, 0)

IF re$ <> MID$(res$, boucle, 1) THEN
cc = cc + 1
IF cc > 1 THEN
CALL centre(23, rougeclair, "Solution = " + MID$(res$, boucle, 1))
CALL ligne23(noir, rouge, 1)
ELSE
CALL erreur2
END IF
COLOR , rouge
GOTO multipli1
ELSE
CALL exact2
END IF

'retenue
hh = 51
COLOR , rouge: LOCATE 12, hh: PRINT " "
IF ret = 1 AND la <> zz + 1 THEN
multipli12:
COLOR , noir
CALL centre(23, blanc, "Tape la retenue")
COLOR blancbrill, rouge
LOCATE 8, 35 - zz: PRINT "_"
LOCATE 12, hh: PRINT "_"
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

r$ = INPUT$(1)

IF ASC(r$) = 27 THEN
CALL quitter(noir, noir)
GOTO multipli12
END IF

IF ASC(r$) < 48 OR ASC(r$) > 57 THEN
CALL chiffreslettres(noir, noir, 1)
GOTO multipli12
END IF

r = VAL(r$)
LOCATE 8, 35 - zz: PRINT r$
LOCATE 12, hh: PRINT r$
IF r <> retenue1 THEN
CALL ligne23(noir, noir, 0)
CALL centre(23, rougeclair, "Retenue =" + STR$(retenue1))
CALL ligne23(noir, rouge, 1)
GOTO multipli12
END IF
'COLOR blancbrill, noir: CALL ligne23(noir, rouge, 0)
END IF

h = h + 1
zz = zz + 1
NEXT boucle '++++++++++++++

flag = 1
GOSUB multiaddposee
v = CSRLIN - 3
GOSUB multiposee

COLOR , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
LOCATE 23, 32
COLOR rougeclair
PRINT "Tu as fait"; cc; "faute"; : IF cc > 1 THEN PRINT "s";
PRINT "."
END IF
CALL getinvimouse(w)

cc = 0
NEXT no '+++++++++

EXIT SUB

multiaddposee:
'operation posee addition
LOCATE 9

FOR kk = 1 TO b
LOCATE , 37 - la
IF flag = 1 THEN
COLOR blancbrill
PRINT a$
ELSE
FOR jj = 1 TO la
IF LEN(res$) - la = 0 THEN
IF jj = boucle THEN COLOR blancbrill ELSE COLOR blanc
ELSE
IF jj = boucle - 1 THEN COLOR blancbrill ELSE COLOR blanc
END IF
PRINT MID$(a$, jj, 1);
NEXT jj
PRINT
COLOR blancbrill
END IF
IF kk <> b THEN LOCATE , 37 - (la + 2): PRINT "+";
NEXT kk
LOCATE , 37 - (la + 2)
lli$ = MID$(ll$, 1, la + 2)
COLOR vertclair: PRINT lli$: COLOR blancbrill
RETURN

multiposee:
LOCATE v
h3 = 49
'oper posee multi
LOCATE , h3 - la
IF flag = 1 THEN
COLOR blancbrill
PRINT a$
ELSE
FOR jj = 1 TO la
IF LEN(res$) - la = 0 THEN
IF jj = boucle THEN COLOR blancbrill ELSE COLOR blanc
ELSE
IF jj = boucle - 1 THEN COLOR blancbrill ELSE COLOR blanc
END IF
PRINT MID$(a$, jj, 1);
NEXT jj
PRINT
COLOR blancbrill
END IF
LOCATE , h3 - (lb + 3): PRINT "x "; b$
LOCATE , (h3 - (la + lb))
COLOR vertclair: PRINT LEFT$(ll$, la + lb): COLOR blancbrill
RETURN

END SUB
 

 

DECLARE SUB niv (limit%, xx%)
DECLARE SUB attendre (tx!)
DECLARE SUB centre (v%, coul%, ph$)
DECLARE SUB chiffreslettres (x%, y%, t%)
DECLARE SUB convertir (z$)
DECLARE SUB entree (y%, z%)
DECLARE SUB erreur2 ()
DECLARE SUB exact2 ()
DECLARE SUB ligne23 (x%, y%, z!)
DECLARE SUB Niveau (ni%, np%)
DECLARE SUB quitter (x%, y%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB solution (sol$)
DECLARE SUB titre ()
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB consigne (nl%, w$, z$, y$)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB MouseHide ()
DECLARE SUB MousePoll (row%, col%, lButton%, rButton%)
'EXERCICES 5 MATH aas pr
'5/5/96
'Daniel CLERC
'version 1.0


DEFINT A-Z
SUB classement (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
'10/4/96

DIM n&(5), n$(5), r%(5), n2!(5), re$(10)
nl = 5: re = 0: cc = 0

'niveau
CALL Niveau(ni, 3)

FOR ne = 1 TO 2 '+++++++++++++

CALL titre
MouseHide
IF ne = 1 THEN
CALL cadre(10, 15, 50, 4, marron)
COLOR , marron
CALL centre(12, blancbrill, "Du plus petit vers le plus grand.")
CALL attendre(1.5)
CALL titre
CALL cadre(4, 18, 44, 2, marron)
COLOR , marron
CALL centre(5, blancbrill, "Du plus petit vers le plus grand.")
d = 1: f = 5: s = 1
ELSE
CALL cadre(10, 15, 50, 4, marron)
COLOR , marron
CALL centre(12, blancbrill, "Du plus grand vers le plus petit.")
CALL attendre(1.5)
CALL titre
CALL cadre(4, 18, 44, 2, marron)
COLOR , marron
CALL centre(5, blancbrill, "Du plus grand vers le plus petit.")
d = 5: f = 1: s = -1
END IF

CALL niv(2, ne)

SELECT CASE ni

CASE 1, 2
FOR i = 1 TO 5
DO
n&(i) = RND * 10 ^ (ni + (RND * 2) + 1)
r%(i) = i
flag = 0
FOR l = 1 TO i - 1
IF n&(i) = n&(l) THEN flag = 1: EXIT FOR
NEXT l
LOOP WHILE flag = 1
NEXT i

CASE 3

n3! = INT(RND * 6) + 3

DO
FOR i = 1 TO 5
DO
IF i <> 2 THEN
n2!(i) = INT((RND * 100) + 1) / 100
ELSE
n2!(i) = INT((RND * 10) + 1) / 10
END IF
r%(i) = i
flag = 0
FOR l = 1 TO i - 1
IF n2!(i) = n2!(l) THEN flag = 1: EXIT FOR
NEXT l
LOOP WHILE flag = 1

NEXT i

'un nombre entier sur les 5 sauf le 2
DO
z = INT(RND * 5) + 1
n2!(z) = 0
LOOP WHILE z = 2

FOR i = 1 TO 5
n2!(i) = n2!(i) + n3!
NEXT i

'un nombre inférieur
z = INT(RND * 5) + 1
n2!(z) = n2!(z) - INT(RND * 2)

'un nombre supérieur
' DO
' z2 = INT(RND * 5) + 1
' LOOP WHILE z2 = z
' n2!(z2) = n2!(z2) + INT(RND * 2) + 1

'vérifier si les 5 nombres sont bien différents
flag = 0
FOR i = 1 TO 5
FOR l = 1 TO 5
IF (n2!(i) = n2!(l)) AND (i <> l) THEN flag = 1: EXIT FOR
NEXT l
NEXT i
LOOP WHILE flag = 1

END SELECT

CALL cadre(8, 18, 15, 10, rouge)
COLOR blancbrill, rouge
LOCATE 9
FOR i = 1 TO 5
IF ni = 3 THEN
w$ = STR$(n2!(i))
CALL convertir(w$)
LOCATE , 25: PRINT w$: PRINT
ELSE
LOCATE , 29 - LEN(LTRIM$(STR$(n&(i)))): PRINT n&(i): PRINT
END IF
NEXT

'tri
FOR i = 1 TO 4
flag = 0
FOR j = 1 TO 5 - i
IF ni = 3 THEN
IF n2!(j + 1) < n2!(j) THEN SWAP n2!(j), n2!(j + 1): SWAP r%(j), r%(j + 1)
ELSE
IF n&(j + 1) < n&(j) THEN SWAP n&(j), n&(j + 1): SWAP r%(j), r%(j + 1)
END IF
flag = 1
NEXT j
IF flag = 0 THEN EXIT FOR
NEXT i

'convertir en chaine
IF ni = 3 THEN
FOR i = 1 TO 5
n$(i) = LTRIM$(STR$(n2!(i)))
CALL convertir(n$(i))
NEXT i
ELSE
FOR i = 1 TO 5
n$(i) = LTRIM$(STR$(n&(i)))
NEXT i
END IF

CALL cadre(8, 47, 15, 10, blanc)
v = 9
LOCATE v: COLOR noir, blanc
FOR j = d TO f STEP s
LOCATE , 50: PRINT LTRIM$(STR$(j)); " -": PRINT
NEXT


FOR ii = d TO f STEP s '+++++++

cla3:
COLOR , noir
CALL centre(23, blanc, "Tape le nombre n°" + LTRIM$(STR$(ii)))

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG
COLOR , blanc
LOCATE v, 54
'CALL inputgen(7, r$, 44, 57, blanc)
GOSUB inpute3

'test si nombre dans liste
flag = 0
FOR x = 1 TO 5
IF n$(x) <> r$ THEN flag = flag + 1
NEXT
CALL ligne23(noir, noir, 0)
IF flag = 5 THEN
COLOR , noir: CALL centre(23, rougeclair, "Ce nombre n'est pas dans la liste.")
CALL ligne23(noir, noir, 1)
GOTO cla3
END IF

COLOR , noir

IF r$ <> n$(ii) THEN
cc = cc + 1
IF cc >= 2 THEN
BEEP
CALL centre(23, rougeclair, "Solution : " + n$(ii))
CALL attendre(2)
ELSE
CALL erreur2
END IF
GOTO cla3
ELSE
CALL exact2
LOCATE ((r%(ii) - 1) * 2) + 9, 22
COLOR , rouge
IF cc = 0 THEN COLOR vertclair ELSE COLOR rougeclair
PRINT CHR$(4)
IF cc = 0 THEN re = re + 1
cc = 0
END IF
CALL ligne23(noir, noir, 0)

v = v + 2
NEXT ii '+++++

CALL entree(noir, noir)

NEXT ne '+++++++++++++++++++++

CALL resultats(re, ni, 3)

EXIT SUB

inpute3:
COLOR noir, blanc
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
ligne = CSRLIN
colon = POS(0)
LOCATE ligne, colon: PRINT " "
LOCATE ligne, colon, 1 ' ,0,7

FOR kk = 1 TO nl + 1
inp5:
IF kk <= 0 THEN kk = 1
inp6:
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
w$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
'LOCATE 22, 1: PRINT v_mouse, h_mouse'===
IF lButton AND kk > 1 THEN
BEEP
ELSEIF lButton THEN
'ligne fleches et entree
IF v_mouse >= 9 AND v_mouse <= 17 THEN
IF h_mouse >= 25 AND h_mouse <= 29 THEN
sc = SCREEN(v_mouse, h_mouse)
IF sc = 32 OR sc = 219 THEN
BEEP
ELSE
LOCATE , , 0
'on cherche les lettres à gauche jusqu'à espace ou h1=1
h1 = h_mouse
DO
sc = SCREEN(v_mouse, h1)
IF sc = 32 OR sc = 219 THEN EXIT DO
h1 = h1 - 1
LOOP WHILE h1 <> 0
h1 = h1 + 1
h3 = h1: mot$ = ""
DO
sc = SCREEN(v_mouse, h3)
IF sc = 32 OR sc = 219 THEN EXIT DO
mot$ = mot$ + CHR$(sc)
h3 = h3 + 1
LOOP WHILE h3 <> 81
mot$ = RTRIM$(LTRIM$(mot$))
LOCATE v_mouse, h1
COLOR rouge, blanc
PRINT mot$
CALL attendre(.3)
LOCATE v_mouse, h1
COLOR blancbrill, rouge
PRINT mot$
r$ = mot$
souris = 2
EXIT DO
END IF
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE w$ = ""

IF souris = 2 THEN
COLOR noir, blanc
LOCATE v, 54: PRINT r$
RETURN
END IF

IF souris = 0 THEN
IF LEN(w$) < 2 THEN rr = ASC(w$) ELSE rr = ASC(RIGHT$(w$, 1))
END IF

IF ni = 3 THEN
IF w$ = "." OR w$ = "?" OR w$ = ";" THEN
w$ = ","
rr = ASC(RIGHT$(w$, 1))
END IF
END IF

re$(kk) = CHR$(rr)


IF rr = 27 THEN
CALL quitter(noir, blanc)
LOCATE v, 54, 1
GOTO inpute3
END IF

IF rr = 13 THEN
EXIT FOR
END IF

IF kk > 1 AND (rr = 8 OR rr = gauche OR rr = 83) THEN
PRINT CHR$(29); " "; CHR$(29);
kk = kk - 1
GOTO inp5
END IF

IF rr < 43 OR rr > 57 THEN '43 à cause de la virgule
CALL chiffreslettres(noir, blanc, 1)
LOCATE v, 54, 1
GOTO inpute3
END IF

IF kk = nl + 1 THEN BEEP: GOTO inp6

PRINT re$(kk);
NEXT kk

PRINT : LOCATE , , 0
r$ = "": FOR jj = 1 TO kk - 1: r$ = r$ + re$(jj): NEXT
r$ = LTRIM$(r$): r$ = RTRIM$(r$)
IF r$ = "" THEN LOCATE v, 54, 1: GOTO inpute3
COLOR , noir
RETURN

END SUB

DEFINT A-Z
SUB probleme3 (re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DIM re$(5 + 1), ca(2, 6), ca2(2, 6), z(3)
CONST gauche = 75, droite = 77, bas = 80, haut = 72
'proportions
'1/12/2001

re = 0: cc = 0

l1$ = "┌───────────────────────────┬─────┬─────┬─────┬─────┬─────┬─────┐"

l0$ = "│ │ │ │ │ │ │ │"

l5$ = "├───────────────────────────┼─────┼─────┼─────┼─────┼─────┼─────┤"

l4$ = "└───────────────────────────┴─────┴─────┴─────┴─────┴─────┴─────┘"

ff$ = CHR$(24) + " " + CHR$(25) + " " + CHR$(27) + " " + CHR$(26)

FOR ii = 1 TO 3 '+++++++++++++++++
ca2(1, 1) = 1
ca2(1, 2) = 1
ca2(1, 3) = 1
ca2(1, 4) = 0
ca2(1, 5) = 1
ca2(1, 6) = 1

ca2(2, 1) = 0
sup = 2: inf = 1
x = INT((sup - inf + 1) * RND + inf)
IF x = 1 THEN
ca2(2, 2) = 0
ca2(2, 3) = 1
ELSE
ca2(2, 2) = 1
ca2(2, 3) = 0
END IF
ca2(2, 4) = 1
ca2(2, 5) = 0
ca2(2, 6) = 0

'1° ligne
ca(1, 1) = 1
ca(1, 2) = 2
sup = 5: inf = 3
ca(1, 3) = INT((sup - inf + 1) * RND + inf)
sup = 10: inf = 6
ca(1, 4) = INT((sup - inf + 1) * RND + inf)
sup = 2: inf = 6
ca(1, 5) = INT((sup - inf + 1) * RND + inf) * 10
ca(1, 6) = 100

DO
f = 0
sup = 20: inf = 10
z(ii) = INT((sup - inf + 1) * RND + inf)
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
ope = z(ii)

'2° ligne
ca(2, 1) = ca(1, 1) * ope
ca(2, 2) = ca(1, 2) * ope
ca(2, 3) = ca(1, 3) * ope
ca(2, 4) = ca(1, 4) * ope
ca(2, 5) = ca(1, 5) * ope
ca(2, 6) = ca(1, 6) * ope

CALL titre

'cadre
COLOR noir, vertclair: LOCATE 21, 2: PRINT "Niveau 3"
LOCATE 21, 77: PRINT 4 - ii

CALL centre(6, jaune, "Proportionnalité")
CALL cadre(8, 6, 67, 10, rouge)
COLOR , rouge
LOCATE 9: h = 8
LOCATE , h: PRINT l1$
LOCATE , h: PRINT l0$
LOCATE , h: PRINT l0$
LOCATE , h: PRINT l0$
LOCATE , h: PRINT l5$
LOCATE , h: PRINT l0$
LOCATE , h: PRINT l0$
LOCATE , h: PRINT l0$
LOCATE , h: PRINT l4$
COLOR vertclair
LOCATE 11, h + 6: PRINT "Nombre d'objets :"
LOCATE 15, h + 6: PRINT "Prix en euros :"

COLOR jaune
h = 38
FOR i = 1 TO 6
LOCATE 11, h
IF ca2(1, i) = 1 THEN PRINT LTRIM$(STR$(ca(1, i)))
h = h + 6
NEXT

h = 38
FOR i = 1 TO 6
LOCATE 15, h
IF ca2(2, i) = 1 THEN PRINT LTRIM$(STR$(ca(2, i)))
h = h + 6
NEXT


v = 15: h = 38

DO
prob2:
IF v = 15 THEN x1 = 2 ELSE x1 = 1

y1 = ((h - 38) / 6) + 1

IF ca2(x1, y1) = 0 THEN
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

LOCATE , , 0
COLOR , noir
CALL centre(23, blanc, "Tape la réponse ou " + ff$)
COLOR , rouge

LOCATE , , 1
souris = 0
DO
LOCATE v, h: nl = 4
GOSUB inpute2
LOOP WHILE r$ = CHR$(13) AND souris = 0

IF souris = 2 THEN GOTO prob2

ELSE
COLOR , noir
LOCATE , , 0
CALL centre(23, 0, SPACE$(80))
CALL centre(23, blanc, ff$)
LOCATE v, h, 1
COLOR blancbrill

DO
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
'ligne fleches et entree
IF v_mouse = 23 THEN
IF h_mouse = 37 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 39 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 41 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 43 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSEIF v_mouse >= 10 AND v_mouse <= 12 THEN
IF h_mouse >= 37 AND h_mouse <= 41 THEN
v = 11: h = 38
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 43 AND h_mouse <= 47 THEN
v = 11: h = 44
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 49 AND h_mouse <= 53 THEN
v = 11: h = 50
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 55 AND h_mouse <= 59 THEN
v = 11: h = 56
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 61 AND h_mouse <= 65 THEN
v = 11: h = 62
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 67 AND h_mouse <= 71 THEN
v = 11: h = 68
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF
ELSEIF v_mouse >= 14 AND v_mouse <= 16 THEN
IF h_mouse >= 37 AND h_mouse <= 41 THEN
v = 15: h = 38
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 43 AND h_mouse <= 47 THEN
v = 15: h = 44
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 49 AND h_mouse <= 53 THEN
v = 15: h = 50
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 55 AND h_mouse <= 59 THEN
v = 15: h = 56
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 61 AND h_mouse <= 65 THEN
v = 15: h = 62
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 67 AND h_mouse <= 71 THEN
v = 15: h = 68
CALL attendre(.2)
souris = 2
EXIT DO
ELSE
BEEP
END IF
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN GOTO prob2

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

IF rr = gauche OR rr = droite OR rr = bas OR rr = haut THEN
r$ = CHR$(rr)
EXIT DO
END IF
IF rr = 27 THEN
CALL quitter(noir, noir)
LOCATE v, h, 1
END IF
LOOP
END IF

SELECT CASE ASC(r$)
CASE gauche
h = h - 6
IF v = 11 AND h < 38 THEN
v = 15: h = 68
ELSEIF v = 15 AND h < 38 THEN
v = 11: h = 68
END IF
GOTO prob2

CASE droite
h = h + 6
IF v = 11 AND h > 68 THEN
v = 15: h = 38
ELSEIF v = 15 AND h > 68 THEN
v = 11: h = 38
END IF
GOTO prob2

CASE bas
v = v + 4
IF v > 15 THEN v = 11
GOTO prob2

CASE haut
v = v - 4
IF v < 11 THEN v = 15
GOTO prob2

END SELECT

r = VAL(r$)

COLOR , noir: CALL centre(23, 0, SPACE$(80))

IF r = ca(x1, y1) THEN
CALL exact2
COLOR vertclair, rouge: LOCATE v, h: PRINT r$
IF cc = 0 THEN
re = re + 2
ELSEIF cc = 1 THEN
re = re + 1
END IF
cc = 0

ELSE
cc = cc + 1
IF cc < 2 THEN
CALL erreur2
COLOR , rouge: LOCATE v, h: PRINT " "
GOTO prob2
ELSE
CALL solution(STR$(ca(x1, y1)))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
COLOR noir, rouge: LOCATE v, h - 1: PRINT "=" + LTRIM$(STR$(ca(x1, y1)))
cc = 0
END IF
END IF


IF v = 15 THEN x1 = 2 ELSE x1 = 1

y1 = ((h - 38) / 6) + 1

ca2(x1, y1) = 1

'test si toutes les cases remplies
f = 0
FOR i = 1 TO 2
FOR j = 1 TO 6
IF ca2(i, j) = 0 THEN f = 1
NEXT j, i

IF f = 0 THEN
COLOR , noir
LOCATE , , 0
CALL centre(23, 0, SPACE$(80))
CALL entree(noir, noir)
EXIT DO
END IF

DO
h = h + 6
IF h > 68 THEN
IF v = 11 THEN v = 15 ELSE v = 11
h = 38
END IF

IF v = 15 THEN x1 = 2 ELSE x1 = 1
y1 = ((h - 38) / 6) + 1

LOOP WHILE ca2(x1, y1) = 1

LOOP

NEXT ii '++++++++++++++++

re = INT(re / 3)
CALL resultats(re, ni, 3)
EXIT SUB

'+++++++++++++

inpute2:
COLOR , rouge
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
ligne = CSRLIN
colon = POS(0)
LOCATE ligne, colon: PRINT " "
LOCATE ligne, colon, 1, 0, 7

FOR kk = 1 TO nl + 1
prob5:
IF kk <= 0 THEN kk = 1
prob6:
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG

souris = 0
DO
r$ = INKEY$

' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton AND kk > 1 THEN
BEEP
ELSEIF lButton THEN
'ligne fleches et entree
IF v_mouse = 23 THEN
IF h_mouse = 47 THEN
'fleche haut
rr = haut
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 49 THEN
'fleche bas
rr = bas
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 51 THEN
'fleche gauche
rr = gauche
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 53 THEN
'fleche droite
rr = droite
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF

ELSEIF v_mouse >= 10 AND v_mouse <= 12 THEN
IF h_mouse >= 37 AND h_mouse <= 41 THEN
v = 11: h = 38
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 43 AND h_mouse <= 47 THEN
v = 11: h = 44
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 49 AND h_mouse <= 53 THEN
v = 11: h = 50
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 55 AND h_mouse <= 59 THEN
v = 11: h = 56
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 61 AND h_mouse <= 65 THEN
v = 11: h = 62
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 67 AND h_mouse <= 71 THEN
v = 11: h = 68
CALL attendre(.2)
souris = 2
EXIT DO

ELSE
BEEP
END IF
ELSEIF v_mouse >= 14 AND v_mouse <= 16 THEN
IF h_mouse >= 37 AND h_mouse <= 41 THEN
v = 15: h = 38
CALL attendre(.2)
souris = 2
EXIT DO
ELSEIF h_mouse >= 43 AND h_mouse <= 47 THEN
v = 15: h = 44
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 49 AND h_mouse <= 53 THEN
v = 15: h = 50
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 55 AND h_mouse <= 59 THEN
v = 15: h = 56
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 61 AND h_mouse <= 65 THEN
v = 15: h = 62
CALL attendre(.2)
souris = 2
EXIT DO

ELSEIF h_mouse >= 67 AND h_mouse <= 71 THEN
v = 15: h = 68
CALL attendre(.2)
souris = 2
EXIT DO
ELSE
BEEP
END IF
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 2 THEN
RETURN
END IF

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

re$(kk) = CHR$(rr)
IF rr = 27 THEN
CALL quitter(noir, rouge)
LOCATE v, h, 1
GOTO inpute2
END IF

IF rr = 13 OR rr = droite THEN
EXIT FOR
END IF

IF (rr = gauche OR rr = droite OR rr = haut OR rr = bas) AND kk = 1 THEN
EXIT FOR
END IF

IF kk > 1 AND (rr = 8 OR rr = gauche OR rr = 83) THEN
PRINT CHR$(29); " "; CHR$(29);
kk = kk - 1
GOTO prob5
END IF

IF rr < 48 OR rr > 57 THEN
CALL chiffreslettres(noir, rouge, 1)
LOCATE v, h, 1
GOTO inpute2
END IF

IF kk = nl + 1 THEN BEEP: GOTO prob6

PRINT re$(kk);
NEXT kk

PRINT : LOCATE , , 0
r$ = "": FOR jj = 1 TO kk - 1: r$ = r$ + re$(jj): NEXT
r$ = LTRIM$(r$): r$ = RTRIM$(r$)
IF r$ = "" THEN r$ = CHR$(rr)
COLOR , noir
RETURN

END SUB

DEFINT A-Z
SUB soustdecimal (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DIM nombre!(2), nombre$(2), l(3), nombr$(2)
'10/4/96 soustractions décimales

ll$ = STRING$(10, 196)
li2$ = STRING$(30, ".")
zero$ = "000000"

re = 0: cc = 0: f = 0: re2 = 0

'présentation
w$ = "Tu vas mettre en colonne"
z$ = "des nombres décimaux."
y$ = "Puis tu effectueras la soustraction."
CALL consigne(3, w$, z$, y$)

FOR no = 1 TO 5 '++++++++++++

CALL titre

IF no = 1 THEN
CALL cadre(11, 20, 40, 2, marron)
COLOR , marron
CALL centre(12, blancbrill, "Le programme te signale les retenues.")
CALL attendre(2)
CALL titre
END IF

CALL niv(5, no)

SELECT CASE no
CASE 1
'2 décimales aux 2 nombres
n1& = 100000: n1bis = 100
n2& = 10000: n2bis = 100

CASE 2
'2 décimales au premier, 1 déci au 2°
n1& = 100000: n1bis = 100
n2& = 1000: n2bis = 10

CASE 3
'1 décimale au 1°, 2 au 2° nombre
n1& = 10000: n1bis = 10
n2& = 100000: n2bis = 100

CASE 4
'2 décimales au 1°, entier au 2°
n1& = 100000: n1bis = 100
n2& = 1000: n2bis = 1

CASE 5
'entier au 1°, 2 déci au 2°
n1& = 1000: n1bis = 1
n2& = 100000: n2bis = 100

END SELECT

'nombre 1
soustdec:
DO
nombre!(1) = INT(RND * n1&) / n1bis
LOOP WHILE nombre!(1) < 100
'on vérifie qu'il y a bien les décimales voulues
n$ = LTRIM$(STR$(nombre!(1)))
l = INSTR(1, n$, "."): IF l = 0 THEN l = LEN(n$)
IF l + LEN(LTRIM$(STR$(n1bis))) - 1 <> LEN(n$) THEN
GOTO soustdec
END IF

'nombre 2
soustdec0:
DO
nombre!(2) = INT(RND * n2&) / n2bis
LOOP WHILE nombre!(2) < 50
'on vérifie qu'il y a bien les décimales voulues
n$ = LTRIM$(STR$(nombre!(2)))
l = INSTR(1, n$, "."): IF l = 0 THEN l = LEN(n$)
IF l + LEN(LTRIM$(STR$(n2bis))) - 1 <> LEN(n$) THEN
GOTO soustdec0
END IF

IF nombre!(1) <= nombre!(2) THEN GOTO soustdec

diff! = nombre!(1) - nombre!(2)
diff$ = LTRIM$(STR$(diff!))

'vérification pour bug décimal ===
'la différence doit avoir 2 décimales
l = INSTR(1, diff$, ".")
IF l + 2 <> LEN(diff$) THEN
GOTO soustdec
END IF

FOR ii = 1 TO 2
nombre$(ii) = LTRIM$(STR$(nombre!(ii)))
CALL convertir(nombre$(ii))
l(ii) = INSTR(1, nombre$(ii), ",")
IF l(ii) = 0 THEN l(ii) = LEN(nombre$(ii)) + 1
NEXT

CALL convertir(diff$)

'on teste pour savoir s'il faut ajouter des zéros à gauche
l = l(1): IF l(2) > l(1) THEN l = l(2)
DO
l(3) = INSTR(1, diff$, ",")
IF l(3) <> l THEN
diff$ = MID$(zero$, 1, l - l(3)) + diff$
ELSE
EXIT DO
END IF
LOOP

'déplacement des nombres
hh = 25: h = 43
LOCATE 11
FOR i = 1 TO 2
LOCATE , hh
PRINT nombre$(i)
PRINT
NEXT

'1° nombre
COLOR , noir
CALL centre(23, blanc, "Regarde")
COLOR , bleu
CALL attendre(.5)
ligne$ = nombre$(1) + LEFT$(li2$, 30 - LEN(nombre$(1)))
LOCATE 11, hh
PRINT ligne$

l = LEN(LTRIM$(STR$(INT(nombre!(1)))))
FOR j = 1 TO h - (hh + l + 1)
ligne$ = STRING$(j, ".") + nombre$(1) + MID$(li2$, 1, 30 - (LEN(nombre$(1)) + j))
CALL attendre(.05)
LOCATE 11, hh: PRINT ligne$
NEXT j

CALL attendre(.5)
LOCATE 11, 1
PRINT SPACE$(80)
LOCATE 11, h - l(1): PRINT nombre$(1)

'2° nombre
v = 13
cc2 = 0
h3 = 0
ligne$ = nombre$(2) + MID$(li2$, 1, (80 - (2 * hh)) - LEN(nombre$(2)))
LOCATE v, hh
PRINT ligne$

DO
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, CHR$(27) + " " + CHR$(26) + " puis " + rt$)

DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

DO
COLOR blancbrill, bleu

DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
IF v_mouse = 23 THEN
IF h_mouse = 35 THEN
'fleche gauche
rr = 75
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche droite
rr = 77
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 44 AND h_mouse <= 46 THEN
'entree
rr = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE rr

CASE 75 'gauche
h3 = h3 - 1
IF h3 < 0 THEN h3 = 0: BEEP
ligne$ = STRING$(h3, ".") + nombre$(2) + MID$(li2$, 1, (80 - (2 * hh)) - (LEN(nombre$(2)) + h3))
LOCATE v, hh: PRINT ligne$

CASE 77 'droite
h3 = h3 + 1
IF h3 > 80 - (LEN(nombre$(2)) + (2 * hh)) THEN h3 = 80 - (LEN(nombre$(2)) + (2 * hh)): BEEP
ligne$ = STRING$(h3, ".") + nombre$(2) + MID$(li2$, 1, (80 - (2 * hh)) - (LEN(nombre$(2)) + h3))
LOCATE v, hh: PRINT ligne$

CASE 27
CALL quitter(noir, noir)

CASE 13
EXIT DO

END SELECT
LOOP

COLOR , noir: LOCATE 23, 1: PRINT SPACE$(80)
IF h3 + l(2) = 18 THEN
CALL exact2
COLOR , bleu
LOCATE v, 1: PRINT SPACE$(80)
LOCATE v, h - l(2): PRINT nombre$(2)
EXIT DO
ELSE
cc2 = cc2 + 1
IF cc2 = 1 THEN re2 = re2 + 1
CALL centre(23, rougeclair, "Les unités sous les unités !")
COLOR vertclair, bleu
LOCATE 11, h - 2: PRINT MID$(nombre$(1), l(1) - 1, 1)
COLOR rougeclair
LOCATE v, h3 + hh + l(2) - 2: PRINT MID$(nombre$(2), l(2) - 1, 1)
CALL attendre(1.5)
END IF
LOOP
v = v + 1

MouseHide
'opération posée
CALL cadre(8, 20, 40, 9, rouge)
COLOR , rouge

h = 43
LOCATE 11, h - l(1): PRINT nombre$(1): l1 = LEN(nombre$(1))
LOCATE 13, h - 6: PRINT "-"
LOCATE 13, h - l(2): PRINT nombre$(2): l2 = LEN(nombre$(2))

LOCATE , (h - 2) - l(3)
COLOR vertclair: PRINT MID$(ll$, 1, l(3) + 4): COLOR blancbrill

'on complète par des 0 à droite
FOR i = 1 TO 2
IF LEN(nombre$(i)) = l(i) - 1 THEN
nombre$(i) = nombre$(i) + ",00"
ELSEIF LEN(nombre$(i)) - l(i) = 1 THEN
nombre$(i) = nombre$(i) + "0"
END IF
NEXT i

'on cherche le plus long nombre
l = 0
FOR i = 1 TO 2
IF LEN(MID$(nombre$(i), 1, l(i) - 1)) > l THEN l = LEN(MID$(nombre$(i), 1, l(i) - 1))
NEXT
'on complète par des 0 à gauche
FOR i = 1 TO 2
nombre$(i) = MID$(zero$, 1, (l + 2) - LEN(MID$(nombre$(i), 1, l(i) - 1))) + nombre$(i)
NEXT i
'on enlève la virgule
FOR i = 1 TO 2
s = INSTR(1, nombre$(i), ",")
nombre$(i) = MID$(nombre$(i), 1, s - 1) + MID$(nombre$(i), s + 1)
NEXT
s = INSTR(1, diff$, ",")
diff$ = MID$(diff$, 1, s - 1) + MID$(diff$, s + 1)


'boucle comparaison
zz = 0
h = 44

FOR boucle = LEN(diff$) TO 1 STEP -1 '+++++++++++++++++++

IF zz = 2 THEN
htemp = (h - LEN(diff$)) + boucle
h = h - 1
END IF

'retenue ?
r1 = VAL(MID$(diff$, boucle, 1))
a1$ = MID$(nombre$(1), LEN(nombre$(1)) - zz, 1)
IF LEN(nombre$(2)) - zz > 0 THEN
b1$ = MID$(nombre$(2), LEN(nombre$(2)) - zz, 1)
ELSE
b1$ = "0"
END IF

soustdec1:
COLOR , noir
IF r1 <> VAL(a1$) - VAL(b1$) THEN
CALL centre(23, blanc, "Attention aux retenues")
ELSE
CALL centre(23, blanc, "Tape la réponse")
END IF

COLOR , rouge
LOCATE 15, (h - LEN(diff$)) + boucle, 1: PRINT "_"
LOCATE 15, (h - LEN(diff$)) + boucle, 1
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

x$ = INPUT$(1)

IF ASC(x$) = 27 THEN
CALL quitter(noir, noir): GOTO soustdec1
END IF
IF ASC(x$) < 48 OR ASC(x$) > 57 THEN
CALL chiffreslettres(noir, noir, 1): GOTO soustdec1
END IF

x = VAL(x$): PRINT x$

LOCATE 23, 1, 0: COLOR , noir: PRINT SPACE$(80)

IF x = r1 THEN
CALL exact2
ELSE
cc = cc + 1
IF cc > 1 THEN
CALL solution(STR$(r1))
CALL ligne23(noir, rouge, 1)
ELSE
CALL erreur2
IF zz < 3 AND no <> 1 THEN
'aide pour les zéros
COLOR jaune, rouge
SELECT CASE no
CASE 2
LOCATE 13, 43 - l(2) + l2: PRINT "0"
CASE 3
LOCATE 11, 43 - l(1) + l1: PRINT "0"
CASE 4
LOCATE 13, 43 - l(2) + l2: PRINT ",00"
CASE 5
LOCATE 11, 43 - l(1) + l1: PRINT ",00"
END SELECT
END IF
END IF
GOTO soustdec1
END IF

zz = zz + 1

NEXT boucle '++++++++++++++++++++

soustdec11:
COLOR , noir
CALL centre(23, blanc, "Tape la virgule")
COLOR , rouge
LOCATE 15, htemp, 1
r$ = INPUT$(1)

IF ASC(r$) = 27 THEN
CALL quitter(noir, noir)
GOTO soustdec11
END IF

IF r$ = "?" OR r$ = ";" OR r$ = "." OR r$ = "," THEN
PRINT ","
ELSE
BEEP
GOTO soustdec11
END IF

'resultats
LOCATE 23, , 0: COLOR , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
LOCATE 23, 32
COLOR rougeclair
PRINT "Tu as fait"; cc; "faute"; : IF cc > 1 THEN PRINT "s";
PRINT "."
END IF
CALL getinvimouse(w)
cc = 0
NEXT no '++++++++++++++++++++

re = re - re2: IF re < 0 THEN re = 0
CALL resultats(re, ni, 3)

END SUB
 

 

DECLARE SUB niv (limit%, xx%)
DECLARE SUB attendre (tx!)
DECLARE SUB centre (v%, coul%, ph$)
DECLARE SUB chiffreslettres (x%, y%, t%)
DECLARE SUB entree (y%, z%)
DECLARE SUB erreur2 ()
DECLARE SUB exact2 ()
DECLARE SUB ligne23 (x%, y%, z!)
DECLARE SUB quitter (x%, y%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB solution (sol$)
DECLARE SUB titre ()
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB MouseHide ()
'EXERCICES 6 MATH aas pr
'5/5/96
'Daniel CLERC
'version 1.0


DEFINT A-Z
SUB add (reponse$, a&(), n%, cc%, v%, h%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, fond%)
'22/3/95
DIM a$(n)
ll$ = STRING$(10, 196)
zero$ = "000000"
MouseHide
s& = 0
FOR i = 1 TO n
a$(i) = LTRIM$(STR$(a&(i)))
s& = s& + a&(i)
NEXT
reponse$ = LTRIM$(STR$(s&))

l = LEN(reponse$) + 1

COLOR blancbrill

MouseHide

'operation posee
FOR i = 1 TO n
LOCATE v + i, h + 2 - LEN(STR$(a&(i)))
PRINT LTRIM$(STR$(a&(i)))
NEXT i

FOR i = 1 TO n - 1
LOCATE v + i + 1, h - l
PRINT "+"
NEXT

LOCATE v + i + 1, h - l
lli$ = MID$(ll$, 1, l + 1)
COLOR vertclair: PRINT lli$: COLOR blancbrill

'boucle comparaison
zz = 0: ret2 = 0

'on cherche le plus long nombre
l = 0
FOR i = 1 TO n
IF LEN(a$(i)) > l THEN l = LEN(a$(i))
NEXT
'on met des 0 à gauche
FOR i = 1 TO n
a$(i) = MID$(zero$, 1, (l + 2) - LEN(a$(i))) + a$(i)
NEXT i

FOR boucle = LEN(reponse$) TO 1 STEP -1 '+++++++++++++++++++

b = 0
FOR i = 1 TO n
b = b + VAL(MID$(a$(i), LEN(a$(i)) - zz, 1))
NEXT i

b = b + ret2
ret = INT(b / 10)
ret2 = ret

add1:
COLOR , noir: CALL centre(23, blanc, "Tape la réponse"): COLOR , fond
LOCATE v + 2 + n, (h - LEN(reponse$)) + boucle, 1
PRINT "_"
LOCATE v + 2 + n, (h - LEN(reponse$)) + boucle

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

x$ = INPUT$(1)

IF ASC(x$) = 27 THEN
CALL quitter(noir, fond): GOTO add1
END IF
IF ASC(x$) < 48 OR ASC(x$) > 57 THEN
CALL chiffreslettres(noir, fond, 1): GOTO add1
END IF

x = VAL(x$): PRINT x$
q = VAL(MID$(reponse$, boucle, 1))

LOCATE , , 0
COLOR , noir
CALL centre(23, 0, SPACE$(80))

IF x = q THEN
CALL exact2
ELSE
cc = cc + 1
IF cc > 1 THEN
CALL solution(STR$(q))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
ELSE
CALL erreur2
END IF
GOTO add1
END IF

'retenue
IF ret > 0 THEN
add2:
COLOR , noir
CALL centre(23, blanc, "Tape la retenue")
COLOR jaune, fond
LOCATE v, (h - 1) - zz, 1
PRINT "_"
LOCATE v, (h - 1) - zz
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

r$ = INPUT$(1)

IF ASC(r$) = 27 THEN
CALL quitter(noir, fond)
GOTO add2
END IF
IF ASC(r$) < 48 OR ASC(r$) > 57 THEN
CALL chiffreslettres(noir, fond, 1)
GOTO add2
END IF

r = VAL(r$): PRINT r$
IF r <> ret THEN
cc = cc + 1
COLOR , noir
LOCATE , , 0
CALL centre(23, 0, SPACE$(80))
CALL centre(23, rougeclair, "Retenue =" + STR$(ret))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
GOTO add2
END IF
END IF
zz = zz + 1

NEXT boucle '++++++++++++++++++++

END SUB

DEFINT A-Z
SUB divi (reponse$, a&, b&, er, v, h, cd%, cd2%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, coul)
DIM r$(9), r(9), q(9), st(9), st$(9), m(9), m$(9), p(5)
'4/5/95
MouseHide
l$ = STRING$(10, 196)

q& = INT(a& / b&)
q$ = LTRIM$(STR$(q&))
reponse$ = q$
b$ = LTRIM$(STR$(b&))
n2 = LEN(b$)
a$ = LTRIM$(STR$(a&))
n1 = LEN(a$)

'si le diviseur divise le même nombre de chiffre alors ff=1
ff = 0: IF VAL(LEFT$(a$, n2)) > b& THEN ff = 1

'max n1 = 5 : max n2 = 2 ===
'IF n1 > 5 OR n2 > 2 THEN STOP '===
'IF a& < b& THEN STOP '===

cd = 0: cc = 0: cc2 = 0: cd2 = 0: cc3 = 0

'affichage
COLOR blancbrill
LOCATE v, h - n1: PRINT a$
la = 7
IF ff = 1 THEN
IF n1 = 3 AND n2 = 1 THEN la = 10
IF n1 = 4 AND n2 = 1 THEN la = 13
IF n1 = 4 AND n2 = 2 THEN la = 10
IF n1 = 5 AND n2 = 2 THEN la = 13
ELSE
IF n1 = 4 AND n2 = 1 THEN la = 10
IF n1 = 5 AND n2 = 2 THEN la = 10
END IF
COLOR vertclair: FOR i = 1 TO la: LOCATE (v - 1) + i, h + 1: PRINT "│": NEXT
COLOR blancbrill
LOCATE v, h + 3: PRINT b$
COLOR vertclair
IF LEN(b$) > LEN(q$) THEN
LOCATE v + 1, h + 2: PRINT LEFT$(l$, LEN(b$) + 2)
ELSE
LOCATE v + 1, h + 2: PRINT LEFT$(l$, LEN(q$) + 2)
END IF
'couleur chiffres
q1& = VAL(MID$(q$, 1, 1)): a1& = q1& * b&: l = LEN(LTRIM$(STR$(a1&)))
IF VAL(MID$(a$, 1, l)) < b& THEN l = l + 1
COLOR blancbrill
IF l <> LEN(a$) THEN
CALL attendre(1)
LOCATE v, h - n1: PRINT MID$(a$, 1, l);
COLOR blanc
PRINT MID$(a$, l + 1)
END IF

'on divise
'boucle result quo
IF ff = 0 THEN limit = n1 - n2 ELSE limit = n1 - n2 + 1
FOR boucle1 = 1 TO limit '/////////////
COLOR , coul

IF cd > 0 THEN 'on abaisse le chiffre suivant
COLOR , noir
CALL centre(23, blanc, "On abaisse le chiffre suivant")
COLOR , coul
CALL attendre(.5)
ancieny$ = y$
y = VAL(MID$(a$, (LEN(s$) + cd), 1)): y$ = LTRIM$(STR$(y))

LOCATE cd2 + v, ((h - 1) - n1 + LEN(s$) + cd): COLOR jaune: PRINT y$: COLOR blancbrill
CALL attendre(1.5)
LOCATE cd2 + v, ((h - 1) - n1 + LEN(s$) + cd): PRINT y$
COLOR blanc
LOCATE v, h - n1: PRINT a$
LOCATE (v + 2) + (cd2 - 4), p: PRINT m$

IF cd > 1 THEN
LOCATE cd2 + ((v + 2) - 5), p(boucle1 - 2)
PRINT ancienst$ + ancieny$
END IF
COLOR blancbrill
LOCATE v, h + 3: PRINT b$
END IF

q(boucle1) = VAL(MID$(q$, boucle1, 1))

divise4:
COLOR , noir
CALL centre(23, 0, SPACE$(80))
CALL centre(23, blanc, "Tu divises")
COLOR blancbrill, coul

LOCATE v + 2, h + 2 + boucle1, 1: PRINT "_"
LOCATE v + 2, h + 2 + boucle1, 1
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

r$ = INPUT$(1)

IF ASC(r$) = 27 THEN
CALL quitter(noir, noir): GOTO divise4
END IF

IF ASC(r$) < 48 OR ASC(r$) > 57 THEN
CALL chiffreslettres(noir, coul, 1): GOTO divise4
END IF

LOCATE , , 0: PRINT r$: r = VAL(r$)
COLOR , noir
CALL centre(23, 0, SPACE$(80))

IF r <> q(boucle1) THEN
cc = cc + 1
IF cc > 1 THEN
CALL solution(STR$(q(boucle1)))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
ELSE
CALL erreur2
END IF
GOTO divise4
ELSE
CALL exact2
END IF

'on multiplie
IF cd = 0 THEN
'premier reste
s = VAL(LEFT$(a$, n2)): t = 1
IF s < b& THEN s = VAL(LEFT$(a$, n2 + 1)): t = 2
s$ = LTRIM$(STR$(s))
ELSE
'reste suivant
s2$ = LTRIM$(STR$(s2)): s = VAL(s2$ + MID$(a$, n2 + t + cd - 1, 1))
END IF

m& = q(boucle1) * b&
m$ = LTRIM$(STR$(m&))
'problème si m& = 0
IF m& = 0 THEN m$ = MID$("00000", 1, LEN(b$))

'boucle pour résultat multi
FOR boucle2 = LEN(m$) TO 1 STEP -1 '/ / / / / / / / / / / / /
d = LEN(m$) + 1 - boucle2
divise6:
COLOR , noir
CALL centre(23, 0, SPACE$(80))
CALL centre(23, blanc, "Tu multiplies")
COLOR blancbrill, coul

IF n2 < 2 THEN tt = 1 ELSE tt = 2
IF ff = 0 THEN
LOCATE cd2 + (v + 1), ((h + tt) - (n1 + LEN(m$)) + cd + boucle2), 1
ELSE
LOCATE cd2 + (v + 1), ((h + tt) - (n1 + LEN(m$)) + cd + boucle2 - 1), 1
END IF
PRINT "_"
IF ff = 0 THEN
LOCATE cd2 + (v + 1), ((h + tt) - (n1 + LEN(m$)) + cd + boucle2), 1
ELSE
LOCATE cd2 + (v + 1), ((h + tt) - (n1 + LEN(m$)) + cd + boucle2 - 1), 1
END IF

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

m$(d) = INPUT$(1)
p = POS(0)

IF ASC(m$(d)) = 27 THEN
CALL quitter(noir, noir): GOTO divise6
END IF

IF ASC(m$(d)) < 48 OR ASC(m$(d)) > 57 THEN
CALL chiffreslettres(noir, coul, 1): GOTO divise6
END IF

LOCATE , , 0: PRINT m$(d): m(d) = VAL(m$(d))
COLOR , noir
CALL centre(23, 0, SPACE$(80))

IF m$(d) <> MID$(m$, boucle2, 1) THEN
cc3 = cc3 + 1
IF cc3 > 1 THEN
CALL solution(MID$(m$, boucle2, 1))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
ELSE
CALL erreur2
END IF
GOTO divise6
ELSE
CALL exact2
END IF
NEXT boucle2 '/ / / / / / / / / / /

st& = s - m&
ancienst$ = st$
st$ = LTRIM$(STR$(st&))

WHILE LEN(st$) <> LEN(m$)
st$ = "0" + st$
WEND

p(boucle1) = p

'la barre de soustraction
COLOR , coul
LOCATE cd2 + (v + 1), p - 1
PRINT "-"
LOCATE cd2 + (v + 2), p
PRINT MID$(l$, 1, LEN(st$))
COLOR blanc
LOCATE v, h + 3: PRINT b$
LOCATE v + 2, h + 3 + (cd): PRINT LTRIM$(STR$(q(boucle1)))

'on retranche
'boucle result reste
FOR boucle3 = LEN(st$) TO 1 STEP -1 '/ / / / / / / / / / / / /
d = LEN(st$) + 1 - boucle3

divise0:
COLOR , noir
CALL centre(23, 0, SPACE$(80))
CALL centre(23, blanc, "Tu retranches")
COLOR blancbrill, coul

IF n2 < 2 THEN tt = 1 ELSE tt = 2
IF ff = 0 THEN
LOCATE cd2 + (v + 3), ((h + tt) - (n1 + LEN(st$)) + cd + boucle3), 1
ELSE
LOCATE cd2 + (v + 3), ((h + tt) - (n1 + LEN(st$)) + cd + boucle3 - 1), 1
END IF
PRINT "_"
IF ff = 0 THEN
LOCATE cd2 + (v + 3), ((h + tt) - (n1 + LEN(st$)) + cd + boucle3), 1
ELSE
LOCATE cd2 + (v + 3), ((h + tt) - (n1 + LEN(st$)) + cd + boucle3 - 1), 1
END IF

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

st$(d) = INPUT$(1)

IF ASC(st$(d)) = 27 THEN
CALL quitter(noir, coul): GOTO divise0
END IF

IF ASC(st$(d)) < 48 OR ASC(st$(d)) > 57 THEN
CALL chiffreslettres(noir, coul, 1): GOTO divise0
END IF

LOCATE , , 0: PRINT st$(d): st(d) = VAL(st$(d))
COLOR , noir
CALL centre(23, 0, SPACE$(80))

IF st$(d) <> MID$(st$, boucle3, 1) THEN
cc2 = cc2 + 1
IF cc2 > 1 THEN
CALL solution(MID$(st$, boucle3, 1))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
ELSE
CALL erreur2
END IF
GOTO divise0
ELSE
CALL exact2
END IF
NEXT boucle3 '/ / / / / / / / / / /

'fin boucle
s2 = st(1) + 10 * st(2) + 100 * st(3) + 1000 * st(4) + 10 ^ 4 * st(5) + 10 ^ 5 * st(6) + 10 ^ 6 * st(7) + 10 ^ 7 * st(8) + 10 ^ 8 * st(9)
cd = cd + 1
cd2 = cd2 + 3

NEXT boucle1 '////////////////

COLOR blancbrill, coul
LOCATE v, h - n1: PRINT a$
LOCATE v + 2, h + 3: PRINT q$
LOCATE v, h + 3: PRINT b$
COLOR blanc
LOCATE (v + 2) + (cd2 - 4), p(boucle1 - 1): PRINT m$
IF cd > 1 THEN
LOCATE (v + 2) + (cd2 - 5), p(boucle1 - 2): PRINT ancienst$; y$
END IF

'result
er = cc + cc2 + cc3

END SUB

DEFINT A-Z
SUB divi4 (re%, ni%, rt$, li$, gg$, pre$, titr$, prog%, nom$, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DIM r$(9), r(9), q(9), st(9), st$(9)
l$ = STRING$(10, 196)
MouseHide

'présentation
CALL titre
CALL cadre(9, 10, 60, 6, marron)
COLOR , marron
CALL centre(11, blancbrill, "Le calcul des restes")
CALL centre(13, blancbrill, "se fera directement (sans poser la soustraction).")

CALL entree(noir, noir)

re = 0
n1 = 4: n2 = 2

FOR no = 1 TO 5
CALL titre
cd = 0: cc = 0: cc2 = 0: er = 0
CALL niv(5, no)
COLOR blancbrill

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique

'tirage
DO
DO
b& = INT(RND * 10 ^ n2)
LOOP WHILE b& = 0 OR b& = 10 ^ n2

DO
q& = INT(RND * 10 ^ (n1 - n2))
LOOP WHILE q& = 0 OR q& = 10 ^ (n1 - n2)

WHILE q& < 10 ^ (n1 - n2 - 1)
q& = q& * 10
WEND

IF b& >= 10 THEN
ajout = 10
ELSE
ajout = b&
END IF
a& = q& * b& + INT(RND * ajout) 'pour opération avec reste

LOOP WHILE LEN(LTRIM$(STR$(a&))) <> n1

q$ = LTRIM$(STR$(q&))
b$ = LTRIM$(STR$(b&))
a$ = LTRIM$(STR$(a&))

CALL cadre(7, 23, 34, 11, rouge)
COLOR , rouge

'affichage
LOCATE 10, 40 - n1: PRINT a$
la = LEN(a$): IF la < 6 THEN la = 6
COLOR vertclair: FOR i = 1 TO la: LOCATE 9 + i, 41: PRINT "│": NEXT
COLOR blancbrill
LOCATE 10, 43: PRINT b$
COLOR vertclair
IF LEN(b$) > LEN(q$) THEN
LOCATE 11, 42: PRINT LEFT$(l$, LEN(b$) + 4)
ELSE
LOCATE 11, 42: PRINT LEFT$(l$, LEN(q$) + 4)
END IF
COLOR blancbrill

'boucle result quo
FOR j = 1 TO (n1 - n2)
IF cd = 0 THEN GOTO divi3
y = VAL(MID$(a$, (LEN(s$) + cd), 1)): y$ = LTRIM$(STR$(y))
LOCATE cd + 10, (39 - n1 + LEN(s$) + cd): COLOR jaune: PRINT y$: COLOR blancbrill
CALL attendre(1)
LOCATE cd + 10, (39 - n1 + LEN(s$) + cd): PRINT y$
divi3:
q(j) = VAL(MID$(q$, j, 1))
divi4:
COLOR , noir
CALL centre(23, blanc, "Tape la réponse")
COLOR blancbrill, rouge
LOCATE 12, 42 + j, 1: PRINT "_"
LOCATE 12, 42 + j, 1
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

r$ = INPUT$(1)

IF ASC(r$) = 27 THEN CALL quitter(noir, rouge): GOTO divi4
IF ASC(r$) < 48 OR ASC(r$) > 57 THEN CALL chiffreslettres(noir, rouge, 1): GOTO divi4
LOCATE , , 0: PRINT r$: r = VAL(r$)

COLOR , noir: LOCATE 23, 1: PRINT SPACE$(80)
IF r <> q(j) THEN GOSUB aidequot: GOTO divi4
'COLOR , noir
CALL exact2
COLOR , rouge
GOSUB analyse
NEXT j

'result
COLOR , noir: LOCATE 23
er = cc + cc2
IF er = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF er < 3 THEN re = re + 1
LOCATE 23, 32
COLOR rougeclair
PRINT "Tu as fait"; er; "faute"; : IF er > 1 THEN PRINT "s";
PRINT "."
END IF
CALL getinvimouse(w)

NEXT no

CALL resultats(re, ni, 4)

EXIT SUB

analyse:
IF cd = 0 THEN GOSUB premrest ELSE GOSUB restesuiv
m& = q(j) * b&
st& = s - m&
br$ = LTRIM$(STR$(st&))

IF st& < 10 THEN br$ = "0" + br$

'boucle result reste
divi1:
FOR e = LEN(br$) TO 1 STEP -1
d = LEN(br$) + 1 - e
divi0:
COLOR , noir
CALL centre(23, blanc, "Tape la réponse")
COLOR blancbrill, rouge
LOCATE cd + 11, (42 - (n1 + LEN(br$)) + cd + e), 1: PRINT "_"
LOCATE cd + 11, (42 - (n1 + LEN(br$)) + cd + e), 1
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

st$(d) = INPUT$(1)

IF ASC(st$(d)) = 27 THEN CALL quitter(noir, rouge): GOTO divi0
IF ASC(st$(d)) < 48 OR ASC(st$(d)) > 57 THEN CALL chiffreslettres(noir, rouge, 1): GOTO divi0

LOCATE , , 0: PRINT st$(d): st(d) = VAL(st$(d))

COLOR , noir: LOCATE 23, 1: PRINT SPACE$(80)
IF st$(d) <> MID$(br$, e, 1) THEN
GOSUB aidereste
GOTO divi0
ELSE
CALL exact2: COLOR , rouge
END IF
NEXT e

'fin boucle
s2 = st(1) + 10 * st(2) + 100 * st(3) + 1000 * st(4) + 10 ^ 4 * st(5) + 10 ^ 5 * st(6) + 10 ^ 6 * st(7) + 10 ^ 7 * st(8) + 10 ^ 8 * st(9)
cd = cd + 1
RETURN

premrest:
s = VAL(LEFT$(a$, n2)): t = 1
IF s < b& THEN s = VAL(LEFT$(a$, n2 + 1)): t = 2
s$ = LTRIM$(STR$(s))
RETURN

restesuiv:
s2$ = LTRIM$(STR$(s2)): s = VAL(s2$ + MID$(a$, n2 + t + cd - 1, 1))
RETURN

aidequot:
cc = cc + 1
IF cc > 1 THEN
CALL solution(STR$(q(j)))
CALL ligne23(noir, rouge, 1)
ELSE
COLOR , noir
CALL erreur2
COLOR , rouge
END IF
RETURN

aidereste:
cc2 = cc2 + 1
IF cc2 > 1 THEN
CALL solution(MID$(br$, e, 1))
CALL ligne23(noir, rouge, 1)
ELSE
COLOR , noir
CALL erreur2
COLOR , rouge
END IF
RETURN

END SUB

DEFINT A-Z
SUB multi (res$, a&, b&, cc%, v, h, no%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, coul)
'28/3/95
DIM res$(4)
ll$ = STRING$(10, 196)
zero$ = "000000"
MouseHide
la = LEN(LTRIM$(STR$(a&)))
a$ = LTRIM$(STR$(a&))
lb = LEN(LTRIM$(STR$(b&)))
b$ = LTRIM$(STR$(b&))
m2 = LEN(b$)

flag = 1: GOSUB multipliposee
vv = 0: numboucle = 0: hh = 0
IF no <> 5 THEN CALL attendre(1)

'boucle comparaison

FOR boucle1 = m2 TO 1 STEP -1 '+ + + + + + + + + + + + + + + +

numboucle = numboucle + 1

res$(numboucle) = LTRIM$(STR$(VAL(MID$(b$, boucle1, 1)) * a&))
res$ = res$(numboucle)

COLOR , coul
IF no = 5 THEN
flag = 1
ELSE
flag = 0
END IF
GOSUB multipliposee

IF numboucle > 1 THEN 'les points //////////////////
COLOR , noir
IF numboucle > 2 THEN
ph$ = "les points"
ELSE
ph$ = "le point"
END IF
CALL centre(23, blanc, "Tape " + ph$)
COLOR , coul
vv = vv + 1: LOCATE vv + (v + 4)
hh = 0

FOR z = 1 TO numboucle - 1
DO
'LOCATE , (h - 1) - hh, 1: PRINT "_"
LOCATE , (h - 1) - hh, 1

zz$ = INPUT$(1)

IF zz$ = "," OR zz$ = ";" OR zz$ = "0" THEN zz$ = "."
LOOP WHILE zz$ <> "."
PRINT ".";
hh = hh + 1
NEXT z
PRINT
END IF '///////////////////

zz = 0: retenue = 0

FOR boucle2 = LEN(res$) TO 1 STEP -1 '+++++++++

'test si retenue
retenue1 = INT(((VAL(MID$(STR$(a&), LEN(STR$(a&)) - zz, 1)) * VAL(MID$(b$, boucle1, 1))) + retenue) / 10)
retenue = retenue1

IF retenue1 <> 0 THEN
ret = 1
ELSE
ret = 0
END IF

COLOR blancbrill, coul
IF no = 5 THEN
flag = 1
ELSE
flag = 0
END IF
GOSUB multipliposee


multipli1:
COLOR , noir: CALL centre(23, blanc, "Tape la réponse")
COLOR blancbrill, coul
LOCATE (v + 4) + vv, (h - 1) - hh, 1
PRINT "_"
LOCATE (v + 4) + vv, (h - 1) - hh, 1

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

re$ = INPUT$(1)

IF ASC(re$) = 27 THEN CALL quitter(noir, coul): GOTO multipli1
IF ASC(re$) < 48 OR ASC(re$) > 57 THEN CALL chiffreslettres(noir, coul, 1): GOTO multipli1
LOCATE , , 0: PRINT re$
COLOR , noir
CALL centre(23, 0, SPACE$(80))
IF re$ <> MID$(res$, boucle2, 1) THEN
GOSUB multiplifaux
GOTO multipli1
ELSE
CALL exact2
END IF

'retenue
COLOR , coul
LOCATE v + 1, h + 3: PRINT " "
IF ret = 1 AND la <> zz + 1 THEN
multi12:
COLOR , noir
CALL centre(23, blanc, "Tape la retenue")
COLOR jaune, coul
LOCATE v + 1, h + 3, 1
PRINT "_"
LOCATE v + 1, h + 3, 1
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

r$ = INPUT$(1)

IF ASC(r$) = 27 THEN
CALL quitter(noir, noir)
GOTO multi12
END IF

IF ASC(r$) < 48 OR ASC(r$) > 57 THEN
CALL chiffreslettres(noir, coul, 1)
GOTO multi12
END IF

r = VAL(r$)
LOCATE v + 1, h + 3: PRINT r$
IF r <> retenue1 THEN
COLOR , noir
CALL centre(23, 0, SPACE$(80))
CALL centre(23, rougeclair, "Retenue =" + STR$(retenue1))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
GOTO multi12
END IF
END IF

hh = hh + 1
zz = zz + 1
NEXT boucle2 '++++++++++

IF numboucle = lb THEN EXIT FOR

NEXT boucle1 '+ + + + + + + + + + + + + + + + + + + + + +

COLOR , coul

IF no = 5 THEN
flag = 1
ELSE
flag = 2
END IF
GOSUB multipliposee

multipli2:
'compar result
IF m2 = 1 THEN GOTO multipli3 ' pour un seul chiffre en bas
vv = vv + 1
COLOR vertclair, coul
LOCATE (v + 4) + vv, ((h - 1) - (la + lb)): PRINT LEFT$(ll$, la + lb + 1)
COLOR blancbrill
res$ = LTRIM$(STR$(a& * b&))
hh = 0

zz = 0: retenue = 0

res$(2) = res$(2) + "0"
res$(3) = res$(3) + "00"
res$(4) = res$(4) + "000"
'on cherche le plus long
l = 0
FOR i = 1 TO m2
IF LEN(res$(i)) > l THEN l = LEN(res$(i)): f = i
NEXT
'on met des 0 à gauche
FOR i = 1 TO m2
res$(i) = MID$(zero$, 1, (l + 2) - LEN(res$(i))) + res$(i)
NEXT i

FOR boucle2 = LEN(res$) TO 1 STEP -1 '++++++++ test Addition


'test si retenue pour l'addition
b = 0
FOR i = 1 TO m2
b = b + VAL(MID$(res$(i), LEN(res$(i)) - zz, 1))
NEXT
b = b + retenue
ret = INT(b / 10)
retenue = ret

multipli4:
COLOR , noir: CALL centre(23, blanc, "Tape la réponse")
COLOR , coul
LOCATE (v + 5) + vv, (h - 1) - hh, 1: PRINT "_"
LOCATE (v + 5) + vv, (h - 1) - hh, 1

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

re$ = INPUT$(1)

IF ASC(re$) = 27 THEN
CALL quitter(noir, noir)
GOTO multipli4
END IF

IF ASC(re$) < 48 OR ASC(re$) > 57 THEN
CALL chiffreslettres(noir, coul, 1)
GOTO multipli4
END IF

LOCATE , , 0: PRINT re$
COLOR , noir
CALL centre(23, 0, SPACE$(80))
IF re$ <> MID$(res$, boucle2, 1) THEN
GOSUB multiplifaux
GOTO multipli4
ELSE
CALL exact2
END IF

IF ret > 0 THEN
multipli20:
COLOR , noir
CALL centre(23, blanc, "Tape la retenue")
COLOR jaune, coul
LOCATE (v + 3), (h - 2) - zz, 1: PRINT "_"
LOCATE (v + 3), (h - 2) - zz, 1
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

r$ = INPUT$(1)

IF ASC(r$) = 27 THEN
CALL quitter(noir, noir)
GOTO multipli20
END IF

IF ASC(r$) < 48 OR ASC(r$) > 57 THEN
CALL chiffreslettres(noir, coul, 1)
GOTO multipli20
END IF

r = VAL(r$)
LOCATE (v + 3), (h - 2) - zz: PRINT r$
IF r <> ret THEN
LOCATE , , 0
COLOR , noir
CALL centre(23, 0, SPACE$(80))
CALL centre(23, rougeclair, "Retenue =" + STR$(ret))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
GOTO multipli20
END IF
END IF


hh = hh + 1
zz = zz + 1
NEXT boucle2 '+++++

multipli3: 'pour un seul chiffre en bas
COLOR , coul: flag = 1: GOSUB multipliposee

EXIT SUB

multiplifaux:
cc = cc + 1
IF cc > 1 THEN
CALL solution(MID$(res$, boucle2, 1))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
ELSE
CALL erreur2
END IF
RETURN

multipliposee: 'flag 1 : blancbrill, flag 2 : blanc, flag 0 : les deux
LOCATE v
h3 = h
'oper posee multi
LOCATE , h3 - la
IF flag = 1 THEN
COLOR blancbrill
PRINT a$
ELSEIF flag = 2 THEN
COLOR blanc
PRINT a$
ELSE
FOR jj = 1 TO la
IF LEN(res$) - la = 0 THEN
IF jj = boucle2 THEN COLOR blancbrill ELSE COLOR blanc
ELSE
IF jj = boucle2 - 1 THEN COLOR blancbrill ELSE COLOR blanc
END IF
PRINT MID$(a$, jj, 1);
NEXT jj
PRINT
END IF
PRINT
COLOR blancbrill
LOCATE , h3 - (lb + 2): PRINT "x ";
IF boucle1 > 0 THEN
IF flag = 1 THEN
COLOR blancbrill
PRINT b$
ELSEIF flag = 2 THEN
COLOR blanc
PRINT b$
ELSE
COLOR blanc: PRINT b$;
COLOR blancbrill: LOCATE , h3 - (lb + 1) + boucle1: PRINT MID$(b$, boucle1, 1)
END IF
ELSE
COLOR blancbrill
PRINT b$
END IF
LOCATE , (h3 - (la + lb))
COLOR vertclair: PRINT LEFT$(ll$, la + lb): COLOR blancbrill
RETURN

END SUB

DEFINT A-Z
SUB soust (reponse$, a&, b&, cc%, v, h, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, fond)
'10/5/95
ll$ = STRING$(10, 196)
MouseHide
'on met en INTEGER les nombres car sinon pb à la compililation
nombre1 = a&: nombre2 = b&
a$ = LTRIM$(STR$(nombre1))
b$ = LTRIM$(STR$(nombre2))
l1 = LEN(a$)
l2 = LEN(b$)

'oper posee
COLOR blancbrill
LOCATE v, (h + 1) - l1: PRINT nombre1
LOCATE v + 2, h - l1: PRINT "-"; SPC(l1 - l2); nombre2
COLOR vertclair
LOCATE v + 3, h - l1: PRINT MID$(ll$, 1, l1 + 2)
COLOR blancbrill

'boucle comparaison
cc = 0
reponse$ = LTRIM$(STR$(nombre1 - nombre2))
l = LEN(reponse$)
IF l + 1 = l1 THEN reponse$ = "0" + reponse$: l = l + 1
IF l + 2 = l1 THEN reponse$ = "00" + reponse$: l = l + 2
IF l + 3 = l1 THEN reponse$ = "000" + reponse$: l = l + 3

boucle = 0
FOR j = l TO 1 STEP -1 '////////////////
r1$ = MID$(reponse$, j, 1)

a1$ = MID$(a$, LEN(a$) - boucle, 1)
IF LEN(b$) - boucle > 0 THEN
b1$ = MID$(b$, LEN(b$) - boucle, 1)
ELSE
b1$ = "0"
END IF

soust1:
COLOR , noir
IF VAL(r1$) <> VAL(a1$) - VAL(b1$) THEN
CALL centre(23, blanc, "Attention aux retenues")
ELSE
CALL centre(23, blanc, "Tape la réponse")
END IF
COLOR blancbrill, fond
LOCATE v + 4, (h + 1) - l + j, 1: PRINT "_"
LOCATE v + 4, (h + 1) - l + j, 1

DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

re$ = INPUT$(1)

IF ASC(re$) = 27 THEN
CALL quitter(noir, fond)
GOTO soust1
END IF

IF ASC(re$) < 48 OR ASC(re$) > 57 THEN
CALL chiffreslettres(noir, fond, 1)
GOTO soust1
END IF

LOCATE , , 0: PRINT re$

COLOR , noir
CALL centre(23, 0, SPACE$(80))

IF re$ = r1$ THEN
CALL exact2
ELSE
cc = cc + 1
IF cc > 1 THEN
CALL solution(r1$)
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
ELSE
CALL erreur2
END IF
GOTO soust1
END IF

boucle = boucle + 1
NEXT j '/////////////////

END SUB
 

 

DECLARE SUB Niveau (ni%, np%)
DECLARE SUB probleme3 (re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DECLARE SUB probleme (ope%, np%, ph$(), do$(), op$(), uni$(), soluni%(), quest$(), re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)
'EXERCICES 7 MATH PRIMAIRE
'5/5/96
'Daniel CLERC
'version 3.0


DEFINT A-Z
SUB choixprobleme (re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)
'5/1/96
'niveau
CALL Niveau(ni, 3)
COLOR , noir

SELECT CASE ni
CASE 1
np = 10
DIM ph$(np), do$(4, np), op$(np), uni$(4, np), soluni(np), quest$(np)
GOSUB dataniveau1
CALL probleme(3, np%, ph$(), do$(), op$(), uni$(), soluni(), quest$(), re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)

CASE 2
np = 14
DIM ph$(np), do$(4, np), op$(np), uni$(4, np), soluni(np), quest$(np)
GOSUB dataniveau2
CALL probleme(4, np%, ph$(), do$(), op$(), uni$(), soluni(), quest$(), re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)

CASE 3
CALL probleme3(re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)

END SELECT

EXIT SUB

dataniveau1:
'data niveau 1 sans divisions
'additions +++++++++++++++++++++++
i = 1 'ok
do$(1, i) = "26"
do$(2, i) = "23"
do$(3, i) = "28"
do$(4, i) = "27"
ph$(i) = "Une école a 4 classes. Il y a " + do$(1, i) + " élèves au CP, " + do$(2, i) + " élèves au CE1-CE2, " + do$(3, i) + " élèves au CM1 et " + do$(4, i) + " élèves au CM2. Calcule le nombre d'élèves dans cette école. "
quest$(i) = " Le nombre d'élèves dans cette école est égal à :"
op$(i) = "1"
soluni(i) = 2
uni$(1, i) = "maîtres": uni$(2, i) = "élèves": uni$(3, i) = "classes": uni$(4, i) = "maîtresses"
'----------------------------------
i = 2 'ok
do$(1, i) = "234"
do$(2, i) = "457"
do$(3, i) = "159"
do$(4, i) = "368"
ph$(i) = "Au cours d'un voyage, un automobiliste effectue 4 étapes successives de " + do$(1, i) + ", " + do$(2, i) + ", " + do$(3, i) + " et " + do$(4, i) + " kilomètres. Quelle distance a-t-il parcouru ? "
quest$(i) = " La distance totale parcourue est égale à :"
op$(i) = "1"
soluni(i) = 3
uni$(1, i) = "voitures": uni$(2, i) = "jours": uni$(3, i) = "kilomètres": uni$(4, i) = "étapes"
'----------------------------------
i = 3 'ok 2001
do$(1, i) = "26"
do$(2, i) = "15"
do$(3, i) = "23"
do$(4, i) = ""
ph$(i) = "Maman va au marché. Elle achète un rôti de veau à " + do$(1, i) + " euros, des escalopes à " + do$(2, i) + " euros et un un gigot d'agneau à " + do$(3, i) + " euros. Combien a-t-elle dépensé ? "
quest$(i) = " Maman a dépensé :"
op$(i) = "1"
soluni(i) = 1
uni$(1, i) = "euros": uni$(2, i) = "aliments": uni$(3, i) = "centimes": uni$(4, i) = "parts"

'soustractions --------------------------
i = 4 'ok 2001
do$(1, i) = "30"
do$(2, i) = "18"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Mélanie va avec ses 2 amies à la fête foraine. Elle a " + do$(1, i) + " euros. Elles font 6 tours de manèges. Cela lui coûte " + do$(2, i) + " euros. Combien lui reste-t-il ? "
quest$(i) = " Argent restant à Mélanie :"
op$(i) = "2"
soluni(i) = 2
uni$(1, i) = "amies": uni$(2, i) = "euros": uni$(3, i) = "manèges": uni$(4, i) = "tours"
'----------------------------------
i = 5 'ok
do$(1, i) = "32"
do$(2, i) = "17"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Florian joue aux billes avec ses 4 amis. Il a " + do$(1, i) + " billes au début de la partie. A la fin, il lui en reste " + do$(2, i) + ". Combien Florian a-t-il perdu de billes ? "
quest$(i) = " Nombre de billes que Florian a perdu :"
op$(i) = "2"
soluni(i) = 4
uni$(1, i) = "euros": uni$(2, i) = "amis": uni$(3, i) = "parties": uni$(4, i) = "billes"
'----------------------------------
i = 6 'ok 2001
do$(1, i) = "165"
do$(2, i) = "107"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Jeudi, Maman est partie au marché avec " + do$(1, i) + " euros. Elle revient 1 heure 30 plus tard avec " + do$(2, i) + " euros. Combien a-t-elle dépensé ? "
quest$(i) = " Argent dépensée par Maman au marché :"
op$(i) = "2"
soluni(i) = 3
uni$(1, i) = "heures": uni$(2, i) = "aliments": uni$(3, i) = "euros": uni$(4, i) = "vêtements"
'----------------------------------
i = 7 'ok
do$(1, i) = "27"
do$(2, i) = "18"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Dans une classe de " + do$(1, i) + " élèves (13 filles et 14 garçons), " + do$(2, i) + " enfants restent à la cantine. Combien d'élèves mangent chez eux le midi ? "
quest$(i) = " Nombre d'élèves mangeant le midi chez eux :"
op$(i) = "2"
soluni(i) = 3
uni$(1, i) = "filles": uni$(2, i) = "garçons": uni$(3, i) = "élèves": uni$(4, i) = "classes"


'multiplications xxxxxxxxxxxxxxxxxxxxxxxx
i = 8 'ok 2001
do$(1, i) = "8"
do$(2, i) = "24"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Monsieur Antoine à 45 ans. Il achète pour ses 2 filles " + do$(1, i) + " disques. Chaque disque coûte " + do$(2, i) + " euros. Combien va-t-il dépenser ? "
quest$(i) = " Les disques vont lui coûter :"
op$(i) = "3"
soluni(i) = 2
uni$(1, i) = "disques": uni$(2, i) = "euros": uni$(3, i) = "filles": uni$(4, i) = "chansons"
'----------------------------------
i = 9 'ok
do$(1, i) = "3"
do$(2, i) = "36"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Pour une projection de diapositives, la maîtresse range les photos dans " + do$(1, i) + " paniers pleins. Chaque panier contient " + do$(2, i) + " diapositives. Calcule le nombre de photos à projeter. "
quest$(i) = " Le nombre de photos est égal à :"
op$(i) = "3"
soluni(i) = 2
uni$(1, i) = "paniers": uni$(2, i) = "photos": uni$(3, i) = "écrans": uni$(4, i) = "enfants"
'----------------------------------
i = 10 'ok 2001
do$(1, i) = "48"
do$(2, i) = "1"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Papa fait le plein d'essence. Il met " + do$(1, i) + " litres. Un litre coûte " + do$(2, i) + " euros. Combien va-t-il dépenser ? "
quest$(i) = " Le plein d'essence va lui coûter :"
op$(i) = "3"
soluni(i) = 3
uni$(1, i) = "litres": uni$(2, i) = "kilomètres": uni$(3, i) = "euros": uni$(4, i) = "voitures"
'----------------------------------

'espace à la fin des phrases
RETURN

dataniveau2:

'additions +++++++++++++++++++++++
i = 1 'ok 2001
do$(1, i) = "17600"
do$(2, i) = "158"
do$(3, i) = "184"
do$(4, i) = ""
ph$(i) = "Monsieur Dupont achète une voiture. Elle vaut " + do$(1, i) + " euros. Il prend, en option, les vitres teintées pour " + do$(2, i) + " euros et l'autoradio pour " + do$(3, i) + " euros. Calcule le prix total de son véhicule. "
quest$(i) = " Le prix total du véhicule est égal à :"
op$(i) = "1"
soluni(i) = 4
uni$(1, i) = "kilomètres": uni$(2, i) = "autoradios": uni$(3, i) = "vitres": uni$(4, i) = "euros"
'----------------------------------
i = 2 'ok 2001
do$(1, i) = "1546"
do$(2, i) = "2050"
do$(3, i) = "948"
do$(4, i) = ""
ph$(i) = "Lors d'un jeu télévisé, un candidat a gagné un camescope, un voyage en Australie et un appareil photo qui valent respectivement " + do$(1, i) + " euros, " + do$(2, i) + " euros, " + do$(3, i) + " euros. Quelle est la valeur totale de ses lots ? "
quest$(i) = " La valeur totale des lots est égale à :"
op$(i) = "1"
soluni(i) = 3
uni$(1, i) = "lots": uni$(2, i) = "jeux": uni$(3, i) = "euros": uni$(4, i) = "candidats"
'----------------------------------
i = 3 'ok 2001
do$(1, i) = "630"
do$(2, i) = "826"
do$(3, i) = "476"
do$(4, i) = ""
ph$(i) = "Monsieur Durand achète pour sa femme et ses 3 enfants une chaîne hi-fi à " + do$(1, i) + " euros, un téléviseur à " + do$(2, i) + " euros et un magnétoscope à " + do$(3, i) + " euros. Combien a-t-il dépensé ? "
quest$(i) = " Monsieur Durand a dépensé :"
op$(i) = "1"
soluni(i) = 1
uni$(1, i) = "euros": uni$(2, i) = "objets": uni$(3, i) = "centimes": uni$(4, i) = "enfants"

'soustractions -----------------
i = 4 'ok
do$(1, i) = "3745"
do$(2, i) = "1852"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Dans une petite ville, il y a " + do$(1, i) + " habitants. " + do$(2, i) + " personnes sont de sexe masculin. Quel est le nombre de personnes de sexe féminin ? "
quest$(i) = " Le nombre de filles est de :"
op$(i) = "2"
soluni(i) = 2
uni$(1, i) = "garçons": uni$(2, i) = "filles": uni$(3, i) = "habitants": uni$(4, i) = "villes"
'----------------------------------
i = 5 'ok
do$(1, i) = "1080"
do$(2, i) = "268"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Les 2 plus longs fleuves en France sont la Loire et le Rhône. La Loire mesure " + do$(1, i) + " kilomètres. Le Rhône mesure " + do$(2, i) + " kilomètres de moins que la Loire. Quelle est la longueur du Rhône ? "
quest$(i) = " La longueur du Rhône est égale à :"
op$(i) = "2"
soluni(i) = 4
uni$(1, i) = "fleuves": uni$(2, i) = "pays": uni$(3, i) = "mètres": uni$(4, i) = "kilomètres"
'----------------------------------
i = 6 'ok
do$(1, i) = "1715"
do$(2, i) = "1638"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Louis XIV, Roi de France, est né en " + do$(2, i) + ". Il est mort en " + do$(1, i) + ". Quelle fut sa durée de vie ? "
quest$(i) = " Louis XIV a vécu :"
op$(i) = "2"
soluni(i) = 3
uni$(1, i) = "rois": uni$(2, i) = "euros": uni$(3, i) = "ans": uni$(4, i) = "croisades"
'----------------------------------
i = 7 'ok
do$(1, i) = "186"
do$(2, i) = "38"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Un avion peut transporter " + do$(1, i) + " passagers répartis en 2 classes. La classe affaire (1° classse) comporte " + do$(2, i) + " places. Calcule le nombre de places en classe économique. "
quest$(i) = " Nombre de places en classe économique :"
op$(i) = "2"
soluni(i) = 4
uni$(1, i) = "avions": uni$(2, i) = "classes": uni$(3, i) = "billets": uni$(4, i) = "passagers"
'----------------------------------
i = 8 'ok
do$(1, i) = "45"
do$(2, i) = "27"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "La différence d'âge entre Florian et son père est de " + do$(2, i) + " ans. Quel est l'âge de Florian sachant que son père a " + do$(1, i) + " ans ? "
quest$(i) = " Florian est âgé de :"
op$(i) = "2"
soluni(i) = 4
uni$(1, i) = "euros": uni$(2, i) = "enfants": uni$(3, i) = "parents": uni$(4, i) = "ans"


'multiplications xxxxxxxxxxxxxxxxxxxxxxxx
i = 9 'ok
do$(1, i) = "348"
do$(2, i) = "2"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Au cours d'une kermesse, les parents d'élèves ont vendu " + do$(1, i) + " parts de gâteaux à " + do$(2, i) + " euros la part. Combien cette vente a-t-elle rapporté ? "
quest$(i) = " La vente a rapporté :"
op$(i) = "3"
soluni(i) = 2
uni$(1, i) = "parts": uni$(2, i) = "euros": uni$(3, i) = "gâteaux": uni$(4, i) = "parents"
'-----------------------------------
i = 10 'ok
do$(1, i) = "25"
do$(2, i) = "13"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Pour sa classe, un instituteur commande " + do$(1, i) + " livres à " + do$(2, i) + " euros l'un. Quel est le coût de cette commande ? "
quest$(i) = " Les livres vont coûter :"
op$(i) = "3"
soluni(i) = 4
uni$(1, i) = "élèves": uni$(2, i) = "pages": uni$(3, i) = "livres": uni$(4, i) = "euros"
'----------------------------------
i = 11 'ok
do$(1, i) = "1598"
do$(2, i) = "12"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Un employé gagne " + do$(1, i) + " euros par mois. Combien gagnera-t-il en " + do$(2, i) + " mois ? "
quest$(i) = " cet employé va gagner en un an :"
op$(i) = "3"
soluni(i) = 2
uni$(1, i) = "travaux": uni$(2, i) = "euros": uni$(3, i) = "mois": uni$(4, i) = "années"


'divisions :::::::::::::::::::::::::
i = 12 'ok
do$(1, i) = "56"
do$(2, i) = "8"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "L'abonnement à une revue coûte " + do$(1, i) + " euros. Il y a " + do$(2, i) + " numéros par an. A combien revient chaque numéro ? "
quest$(i) = " Un numéro revient à :"
op$(i) = "4"
soluni(i) = 1
uni$(1, i) = "euros": uni$(2, i) = "numéros": uni$(3, i) = "revues": uni$(4, i) = "pages"
'----------------------------------
i = 13 'ok
do$(1, i) = "276"
do$(2, i) = "3"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "A un jeu, " + do$(2, i) + " personnes ont joué ensemble. Elles ont gagné " + do$(1, i) + " euros. Quel argent ont-elles gagné chacune ? "
quest$(i) = " Chaque personne a gagné :"
op$(i) = "4"
soluni(i) = 2
uni$(1, i) = "jeux": uni$(2, i) = "euros": uni$(3, i) = "personnes": uni$(4, i) = "centimes"
'----------------------------------
i = 14 'ok
do$(1, i) = "136"
do$(2, i) = "4"
do$(3, i) = ""
do$(4, i) = ""
ph$(i) = "Pour un cross scolaire, " + do$(1, i) + " enfants se sont inscrits. Le responsable veut faire " + do$(2, i) + " départs avec un nombre identique de participants. Calcule le nombre d'enfants à chaque départ. "
quest$(i) = " Le nombre d'enfants à chaque départ est égal à :"
op$(i) = "4"
soluni(i) = 3
uni$(1, i) = "classes": uni$(2, i) = "équipes": uni$(3, i) = "enfants": uni$(4, i) = "matchs"
'----------------------------------

'espace à la fin des phrases
RETURN

END SUB

 

 

DECLARE SUB niv (limit%, xx%)
DECLARE SUB attendre (tx!)
DECLARE SUB centre (v%, coul%, ph$)
DECLARE SUB chiffreslettres (x%, y%, t%)
DECLARE SUB convertir (z$)
DECLARE SUB convertir2 (no$)
DECLARE SUB entree (y%, z%)
DECLARE SUB erreur2 ()
DECLARE SUB exact2 ()
DECLARE SUB fleches (v%, h%, w$(), np%, r%, coul%, drap%, v2%, h3%)
DECLARE SUB ligne23 (x%, y%, z!)
DECLARE SUB quitter (x%, y%)
DECLARE SUB resultats (re%, ni%, nbniv%)
DECLARE SUB solution (sol$)
DECLARE SUB titre ()
DECLARE SUB cadre (v%, h%, l%, nli%, c%)
DECLARE SUB consigne (nl%, w$, z$, y$)
DECLARE SUB getinvimouse (rr%)
DECLARE SUB trouvemot (m$, m$(), nm%)
DECLARE SUB add (reponse$, a&(), n%, cc%, v%, h%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, fond%)
DECLARE SUB divi (reponse$, a&, b&, er%, v%, h%, cd%, cd2%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, coul%)
DECLARE SUB multi (res$, a&, b&, cc%, v%, h%, no%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, coul%)
DECLARE SUB soust (reponse$, a&, b&, cc%, v%, h%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, fond%)
DECLARE SUB MouseHide ()
DECLARE SUB MousePoll (row%, col%, lButton%, rButton%)
DECLARE SUB MouseShow ()
'exo8 26/1/97 aas primaire
'daniel clerc
'version 1.1

DEFINT A-Z
SUB addecimal (re%, ni%, rt$, gg$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%)
DIM nombre!(9), nombre$(9), z(5), l(5)
'10/4/96 addition décimales

ll$ = STRING$(10, 196)
li2$ = STRING$(30, ".")
zero$ = "000000"

re = 0: cc = 0: f = 0: ret = 0: re2 = 0

'présentation
w$ = "Tu vas mettre en colonne"
z$ = "des nombres décimaux."
y$ = "Puis tu effectueras l'addition."
CALL consigne(3, w$, z$, y$)

FOR no = 1 TO 5 '++++++++++++

CALL titre
CALL niv(5, no)
'tirage
'1° nombre avec 1 décimale
DO
nombre!(1) = INT(RND * 100000) / 10
LOOP WHILE nombre!(1) < 1000 OR (nombre!(1)) = INT(nombre!(1))

FOR ii = 1 TO 3
DO
f = 0
z(ii) = INT(RND * 3) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1
z = z(ii)

SELECT CASE z
CASE 1
'nombre avec 2 décimales
DO
DO
nombre!(ii + 1) = INT(RND * 100000) / 100
LOOP WHILE nombre!(ii + 1) < 100 OR (nombre!(ii + 1)) = INT(nombre!(ii + 1))
n$ = LTRIM$(STR$(nombre!(ii + 1)))
l = INSTR(1, n$, ".")
LOOP WHILE l + 2 <> LEN(n$)
verif$ = RIGHT$(n$, 1)

CASE 2
'nombre entier
DO
nombre!(ii + 1) = INT(RND * 10000)
LOOP WHILE nombre!(ii + 1) < 1000

CASE 3
'nombre avec 1 décimale
DO
nombre!(ii + 1) = INT(RND * 10000) / 10
LOOP WHILE nombre!(ii + 1) < 100 OR (nombre!(ii + 1)) = INT(nombre!(ii + 1))

END SELECT
NEXT ii

FOR ii = 1 TO 4
nombre$(ii) = LTRIM$(STR$(nombre!(ii)))
CALL convertir(nombre$(ii))
l(ii) = INSTR(1, nombre$(ii), ",")
IF l(ii) = 0 THEN l(ii) = LEN(nombre$(ii)) + 1
NEXT

somme! = nombre!(1) + nombre!(2) + nombre!(3) + nombre!(4)
somme$ = LTRIM$(STR$(somme!))
CALL convertir(somme$)
l(5) = INSTR(1, somme$, ",")

'vérification pour bug décimal ===
l = INSTR(1, somme$, ",")
IF l + 2 <> LEN(somme$) THEN
'correction de l'erreur
somme$ = MID$(somme$, 1, LEN(somme$) - 2) + verif$
w$ = somme$
CALL convertir2(w$)
somme! = VAL(w$)
END IF

'déplacement des nombres

hh = 25: h = 43
LOCATE 10
FOR i = 1 TO 4
LOCATE , hh
PRINT nombre$(i)
NEXT
'1° nombre
COLOR , noir
CALL centre(23, blanc, "Regarde")
COLOR , bleu
CALL attendre(.5)
ligne$ = nombre$(1) + LEFT$(li2$, 30 - LEN(nombre$(1)))
LOCATE 10, hh
PRINT ligne$

l = LEN(LTRIM$(STR$(INT(nombre!(1)))))
FOR j = 1 TO h - (hh + l + 1)
ligne$ = STRING$(j, ".") + nombre$(1) + MID$(li2$, 1, 30 - (LEN(nombre$(1)) + j))
CALL attendre(.05)
LOCATE 10, hh: PRINT ligne$
NEXT j
CALL attendre(.5)
LOCATE 10, 1
PRINT SPACE$(80)
LOCATE 10, h - l(1): PRINT nombre$(1)

'les autres nombres
v = 11
cc2 = 0
FOR kk = 2 TO 4
h3 = 0
ligne$ = nombre$(kk) + MID$(li2$, 1, (80 - (2 * hh)) - LEN(nombre$(kk)))
LOCATE v, hh
PRINT ligne$

DO
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)
CALL centre(23, blanc, CHR$(27) + " " + CHR$(26) + " puis " + rt$)

DEF SEG = 0
POKE &H417, (PEEK(&H417) AND &H9F)'non numérique
DEF SEG

DO
COLOR blancbrill, bleu


DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO
r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
IF v_mouse = 23 THEN
IF h_mouse = 35 THEN
'fleche gauche
rr = 75
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse = 37 THEN
'fleche droite
rr = 77
CALL attendre(.3)
souris = 1
EXIT DO
ELSEIF h_mouse >= 44 AND h_mouse <= 46 THEN
'entree
rr = 13
CALL attendre(.3)
souris = 1
EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF
LOOP WHILE r$ = ""

IF souris = 0 THEN
IF LEN(r$) < 2 THEN rr = ASC(r$) ELSE rr = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE rr

CASE 75 'gauche
h3 = h3 - 1
IF h3 < 0 THEN h3 = 0: BEEP
ligne$ = STRING$(h3, ".") + nombre$(kk) + MID$(li2$, 1, (80 - (2 * hh)) - (LEN(nombre$(kk)) + h3))
LOCATE v, hh: PRINT ligne$

CASE 77 'droite
h3 = h3 + 1
IF h3 > 80 - (LEN(nombre$(kk)) + (2 * hh)) THEN h3 = 80 - (LEN(nombre$(kk)) + (2 * hh)): BEEP
ligne$ = STRING$(h3, ".") + nombre$(kk) + MID$(li2$, 1, (80 - (2 * hh)) - (LEN(nombre$(kk)) + h3))
LOCATE v, hh: PRINT ligne$

CASE 27
CALL quitter(noir, noir)

CASE 13
EXIT DO

END SELECT
LOOP

COLOR , noir: LOCATE 23, 1: PRINT SPACE$(80)
IF h3 + l(kk) = 18 THEN
CALL exact2
COLOR , bleu
LOCATE v, 1: PRINT SPACE$(80)
LOCATE v, h - l(kk): PRINT nombre$(kk)
EXIT DO
ELSE
cc2 = cc2 + 1
IF cc2 = 1 THEN re2 = re2 + 1
CALL centre(23, rougeclair, "Les unités sous les unités !")
COLOR vertclair, bleu
LOCATE 10, h - 2: PRINT MID$(nombre$(1), l(1) - 1, 1)
COLOR rougeclair
LOCATE v, h3 + hh + l(kk) - 2: PRINT MID$(nombre$(kk), l(kk) - 1, 1)
CALL attendre(1.5)
END IF
LOOP
v = v + 1
NEXT kk

MouseHide
CALL cadre(7, 20, 40, 10, rouge)
COLOR , rouge
'opération posée
LOCATE 10
h = 43
FOR i = 1 TO 4
LOCATE , h - l(i): PRINT nombre$(i)
IF i <> 4 THEN
LOCATE , h - 7: PRINT "+";
END IF
NEXT

LOCATE , (h - 2) - l(5)
COLOR vertclair: PRINT MID$(ll$, 1, l(5) + 4): COLOR blancbrill

'LOCATE , h - l(5): PRINT somme$

'on complète par des 0 à droite
FOR i = 1 TO 4
IF LEN(nombre$(i)) = l(i) - 1 THEN
nombre$(i) = nombre$(i) + ",00"
ELSEIF LEN(nombre$(i)) - l(i) = 1 THEN
nombre$(i) = nombre$(i) + "0"
END IF
NEXT i

'on cherche le plus long nombre
l = 0
FOR i = 1 TO 4
IF LEN(MID$(nombre$(i), 1, l(i) - 1)) > l THEN l = LEN(MID$(nombre$(i), 1, l(i) - 1))
NEXT
'on complète par des 0 à gauche
FOR i = 1 TO 4
nombre$(i) = MID$(zero$, 1, (l + 2) - LEN(MID$(nombre$(i), 1, l(i) - 1))) + nombre$(i)
NEXT i
'on enlève la virgule
FOR i = 1 TO 4
s = INSTR(1, nombre$(i), ",")
nombre$(i) = MID$(nombre$(i), 1, s - 1) + MID$(nombre$(i), s + 1)
NEXT
s = INSTR(1, somme$, ",")
somme$ = MID$(somme$, 1, s - 1) + MID$(somme$, s + 1)


'boucle comparaison
zz = 0: ret2 = 0
h = 44

FOR boucle = LEN(somme$) TO 1 STEP -1 '+++++++++++++++++++

IF zz = 2 THEN
htemp = (h - LEN(somme$)) + boucle
h = h - 1
END IF

b = 0
FOR i = 1 TO 4
b = b + VAL(MID$(nombre$(i), LEN(nombre$(i)) - zz, 1))
NEXT i

b = b + ret2
ret = INT(b / 10)
ret2 = ret

addec1:
COLOR , noir: CALL centre(23, blanc, "Tape la réponse"): COLOR , rouge
LOCATE 15, (h - LEN(somme$)) + boucle, 1: PRINT "_"
LOCATE 15, (h - LEN(somme$)) + boucle, 1
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

x$ = INPUT$(1)

IF ASC(x$) = 27 THEN
CALL quitter(noir, noir): GOTO addec1
END IF
IF ASC(x$) < 48 OR ASC(x$) > 57 THEN
CALL chiffreslettres(noir, noir, 1): GOTO addec1
END IF

x = VAL(x$): PRINT x$
q = VAL(MID$(somme$, boucle, 1))

LOCATE 23, 1, 0: COLOR , noir: PRINT SPACE$(80)

IF x = q THEN
CALL exact2
ELSE
cc = cc + 1
IF cc > 1 THEN
CALL solution(STR$(q))
CALL ligne23(noir, rouge, 1)
ELSE
CALL erreur2
END IF
GOTO addec1
END IF

'retenue
IF ret > 0 THEN
addec2:
COLOR , noir: CALL centre(23, blanc, "Tape la retenue")
COLOR , rouge
IF zz = 1 THEN
LOCATE 9, (h - 2) - zz, 1: PRINT "_"
LOCATE 9, (h - 2) - zz, 1
ELSE
LOCATE 9, (h - 1) - zz, 1: PRINT "_"
LOCATE 9, (h - 1) - zz, 1
END IF
COLOR blancbrill, rouge
DEF SEG = 0
POKE &H417, (PEEK(&H417) OR &H40)'MAJ
POKE &H417, (PEEK(&H417) OR &h30)'numérique
DEF SEG

r$ = INPUT$(1)
IF ASC(r$) = 27 THEN
CALL quitter(noir, rouge)
GOTO addec2
END IF
IF ASC(r$) < 48 OR ASC(r$) > 57 THEN
CALL chiffreslettres(noir, rouge, 1)
GOTO addec2
END IF

r = VAL(r$): PRINT r$
IF r <> ret THEN
cc = cc + 1
COLOR , noir: LOCATE 23, 1, 0: PRINT SPACE$(80)
CALL centre(23, rougeclair, "Retenue =" + STR$(ret))
CALL ligne23(noir, noir, 1)
GOTO addec2
END IF
COLOR blancbrill, noir: CALL ligne23(noir, rouge, 0)
END IF

zz = zz + 1

NEXT boucle '++++++++++++++++++++

addec11:
COLOR , noir
CALL centre(23, blanc, "Tape la virgule")
COLOR blancbrill, rouge
LOCATE 15, htemp, 1
r$ = INPUT$(1)

IF ASC(r$) = 27 THEN
CALL quitter(noir, noir)
GOTO addec11
END IF

IF r$ = "?" OR r$ = ";" OR r$ = "." OR r$ = "," THEN
PRINT ","
ELSE
BEEP
GOTO addec11
END IF

'resultats
LOCATE 23, , 0: COLOR , noir
IF cc = 0 THEN
re = re + 2
CALL centre(23, jaune, "Opération exacte")
ELSE
IF cc = 1 THEN re = re + 1
LOCATE 23, 32
COLOR rougeclair
PRINT "Tu as fait"; cc; "faute"; : IF cc > 1 THEN PRINT "s";
PRINT "."
END IF
CALL getinvimouse(w)
cc = 0
NEXT no

re = re - re2: IF re < 0 THEN re = 0
CALL resultats(re, ni, 3)

END SUB

DEFINT A-Z
SUB probleme (ope%, np%, ph$(), do$(), op$(), uni$(), soluni(), quest$(), re%, ni%, rt$, gg$, gg2$, pre$, titr$, prog%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, couleur%)
'1/12/2001
DIM m$(200), ligne(10), ligne2(10), z(5)
DIM d(4), p$(4), res&(4), nombre&(4), un$(4)
CONST gauche = 75, droite = 77, bas = 80, haut = 72
p$(1) = "addition": p$(2) = "soustraction": p$(3) = "multiplication"
p$(4) = "division"

IF vertclair = 15 THEN vertclair = 7

re = 0: ct = 0

'présentation
w$ = "Tu vas choisir l'opérateur"
z$ = "et les données d'un problème."
y$ = "Puis tu effectueras l'opération."
CALL consigne(3, w$, z$, y$)

FOR ii = 1 TO ope '++++++++++++++++++++++++++++++

CALL titre
CALL niv(ope, ii)

'tirage de l'opérateur
DO
f = 0
z(ii) = INT(RND * ope) + 1
FOR j = 1 TO ii - 1
IF z(ii) = z(j) THEN f = 1: EXIT FOR
NEXT
LOOP WHILE f = 1

operateur = z(ii)

'tirage du problème
DO
pb = INT(RND * np) + 1
LOOP WHILE operateur <> VAL(op$(pb))

op$ = op$(pb)

IF op$ = "1" THEN
signe$ = "+"
ELSEIF op$ = "2" THEN
signe$ = "-"
ELSEIF op$ = "3" THEN
signe$ = "x"
ELSEIF op$ = "4" THEN
signe$ = ":"
END IF

'affect mots
m$ = ph$(pb)
FOR i = 1 TO 10: ligne(i) = 0: NEXT
FOR i = 1 TO 10: ligne2(i) = 0: NEXT

CALL trouvemot(m$, m$(), nm)

flag = 1

'on mémorise les mots à gauche
i = 1: l2 = 0: li = 0
DO
l = LEN(m$(i))
l2 = l2 + l

IF l2 > 80 THEN
i = i - 1: l2 = 0
ELSEIF l2 = 80 THEN
l2 = 0
ELSEIF l2 = 80 - 1 THEN
l2 = 0
ELSE
'ligne() indique la valeur de la place du 1° mot à gauche
'ligne2() indique le nombre de mots sur la ligne
IF l2 = LEN(m$(i)) THEN
ligne2(li) = i - ligne(li)
li = li + 1
ligne(li) = i
END IF
l2 = l2 + 1

END IF
COLOR blancbrill
i = i + 1
LOOP WHILE i <= nm

ligne2(li) = nm - ligne(li) + 1
limax = li

'saisir l'opérateur '/////////////////////////////
flag = 0: GOSUB affichetexte

DO
v = 14: h = 34
COLOR , bleu
CALL centre(v - 2, vertclair, "Choisis l'opérateur")
CALL fleches(v, h, p$(), ope, op, rouge, 1, 23, 35)
COLOR , noir
LOCATE 23, 1: PRINT SPACE$(80)

IF op = VAL(op$) THEN
CALL exact2
IF ct = 0 THEN
re = re + 3
ELSEIF ct = 1 THEN
re = re + 1
END IF
ct = 0
EXIT DO
ELSE
ct = ct + 1
IF ct < 3 THEN
CALL erreur2
ELSE
CALL solution(p$(VAL(op$)))
CALL attendre(1.5)
CALL centre(23, 0, SPACE$(80))
END IF
END IF
LOOP

'saisir les données '////////////////////////////
CALL titre
CALL niv(ope, ii)
IF do$(4, pb) <> "" AND op$ = "1" THEN
limit = 4
ELSEIF do$(3, pb) <> "" AND op$ = "1" THEN
limit = 3
ELSE
limit = 2
END IF

IF limit = 3 THEN
p$ = "... + ... +"
ELSEIF limit = 4 THEN
p$ = "... + ... + ... +"
ELSE
p$ = "... " + signe$
END IF
p$ = p$ + " ... = ..."

h = INT(41 - (LEN(p$) + 4) / 2)
CALL cadre(14, h, LEN(p$) + 2, 4, rouge%)
COLOR , rouge%
CALL centre(16, jaune, p$)


'place désigne la place sur la ligne
place = 1
'flag désigne le numéro du mot
flag = 1
'li désigne la ligne en cours
li = 1

FOR boucle = 1 TO limit '*************************

DO

COLOR , noir
CALL centre(23, blanc, gg2$)
COLOR , bleu

CALL centre(12, vertclair, "Choisis la" + STR$(boucle) + "° donnée du problème.")

DO

GOSUB affichetexte

'saisie du mot
DEF SEG = 0
POKE 1050, PEEK(1052)
DEF SEG
souris = 0
DO

r$ = INKEY$
' Obtient l'emplacement de la souris et l'état des boutons.
MousePoll v_mouse, h_mouse, lButton, rButton
IF lButton THEN
IF v_mouse >= 7 AND v_mouse <= 10 THEN '4 lignes ===
sc = SCREEN(v_mouse, h_mouse)
IF sc = 32 THEN
BEEP
ELSE
'on cherche les lettres à gauche jusqu'à espace ou h1=1
h1 = h_mouse
DO
sc = SCREEN(v_mouse, h1)
IF sc = 32 THEN EXIT DO
h1 = h1 - 1
LOOP WHILE h1 <> 0
h1 = h1 + 1
h3 = h1: mot$ = ""
DO
sc = SCREEN(v_mouse, h3)
IF sc = 32 THEN EXIT DO
mot$ = mot$ + CHR$(sc)
h3 = h3 + 1
LOOP WHILE h3 <> 81

souris = 1
tempflag = flag: flag = 0: GOSUB affichetexte
flag = tempflag
LOCATE v_mouse, h1
IF couleur = 1 THEN COLOR blancbrill, vert ELSE COLOR noir, blanc
PRINT mot$
CALL attendre(.3)
res&(boucle) = VAL(mot$)
EXIT DO
END IF
ELSEIF v_mouse = 23 THEN
IF h_mouse >= 46 AND h_mouse <= 48 THEN
r = 13
CALL attendre(.3)
souris = 2: EXIT DO
ELSEIF h_mouse = 33 THEN
'haut
r = 72
CALL attendre(.2)
souris = 2: EXIT DO
ELSEIF h_mouse = 35 THEN
'bas
r = 80
CALL attendre(.2)
souris = 2: EXIT DO
ELSEIF h_mouse = 37 THEN
'gauche
r = 75
CALL attendre(.2)
souris = 2: EXIT DO
ELSEIF h_mouse = 39 THEN
'droite
r = 77
CALL attendre(.2)
souris = 2: EXIT DO
ELSE
BEEP
END IF
ELSE
BEEP
END IF
END IF

LOOP WHILE r$ = ""

IF souris = 1 THEN EXIT DO

IF souris = 0 THEN
IF LEN(r$) < 2 THEN r = ASC(r$) ELSE r = ASC(RIGHT$(r$, 1))
END IF

SELECT CASE r

CASE 27
CALL quitter(noir, bleu)

CASE droite
flag = flag + 1
IF flag > nm THEN
flag = 1: li = 1: place = 1
ELSEIF flag = ligne(li + 1) THEN
li = li + 1
place = (flag - ligne(li)) + 1
ELSE
place = (flag - ligne(li)) + 1
END IF

CASE gauche
flag = flag - 1
IF flag = 0 THEN
flag = nm: li = limax: place = ligne2(limax)
ELSEIF flag = ligne(li) - 1 THEN
li = li - 1
place = (flag - ligne(li)) + 1
ELSE
place = (flag - ligne(li)) + 1
END IF

CASE haut
li = li - 1
IF li = 0 THEN
li = limax
IF place > ligne2(limax) THEN place = ligne2(limax)
flag = ligne(limax) + place - 1
ELSE
IF place > ligne2(li) THEN place = ligne2(li)
flag = ligne(li) + place - 1
END IF

CASE bas
li = li + 1
IF li > limax THEN
'on retourne sur la 1° ligne
li = 1
IF place > ligne2(1) THEN place = ligne2(1)
flag = place
ELSE
IF place > ligne2(li) THEN place = ligne2(li)
flag = ligne(li) + place - 1
END IF

CASE 81 'pgdown
li = limax: flag = nm: place = ligne2(limax)

CASE 73 'pgup
li = 1: flag = 1: place = 1

CASE 71 'début
place = 1: flag = ligne(li)

CASE 79 'fin
place = ligne2(li): flag = ligne(li) + place - 1

CASE 13
'trouver le mot choisi
res&(boucle) = VAL(m$(flag))
EXIT DO

CASE ELSE
BEEP

END SELECT

LOOP

COLOR , noir
LOCATE 23, 20: PRINT SPACE$(40)

'test si nombre selectionné
IF res&(boucle) = 0 THEN
BEEP: CALL centre(23, rougeclair, "Tu dois choisir un nombre.")
CALL attendre(2)
CALL centre(23, blanc, SPACE$(80))
ELSE

SELECT CASE VAL(op$)
CASE 1, 3
'additions & multi commutatives
f = 0
FOR i = 1 TO limit
IF res&(boucle) = VAL(do$(i, pb)) THEN f = 1
NEXT
IF f = 0 THEN
BEEP: CALL centre(23, rougeclair, "Tu as choisi une donnée inutile.")
ct = ct + 1
CALL attendre(2)
CALL centre(23, blanc, SPACE$(80))
ELSE
'on test si la donnée n'a pas déjà été choisie
f = 0
FOR j = 1 TO boucle - 1
IF res&(boucle) = res&(j) THEN f = 1: EXIT FOR
NEXT

IF f = 1 THEN
BEEP: CALL centre(23, rougeclair, "Tu as déjà choisi cette donnée.")
CALL attendre(2)
CALL centre(23, blanc, SPACE$(80))
ELSE
LOCATE 23, 1: PRINT SPACE$(80)
CALL exact2
EXIT DO
END IF
END IF

CASE 2, 4
'soustractions & divisions non commutatives
IF res&(boucle) = VAL(do$(boucle, pb)) THEN
LOCATE 23, 1: PRINT SPACE$(80)
CALL exact2
EXIT DO

ELSEIF boucle = 1 AND res&(boucle) = VAL(do$(boucle + 1, pb)) THEN
BEEP: CALL centre(23, rougeclair, "Tu as choisi la 2° donnée.")
ct = ct + 1
CALL attendre(2)
CALL centre(23, blanc, SPACE$(80))

ELSEIF boucle = 2 AND res&(boucle) = VAL(do$(boucle - 1, pb)) THEN
BEEP: CALL centre(23, rougeclair, "Tu as choisi la 1° donnée.")
ct = ct + 1
CALL attendre(2)
CALL centre(23, blanc, SPACE$(80))

ELSE
BEEP: CALL centre(23, rougeclair, "Tu as choisi une donnée inutile.")
CALL attendre(2)
ct = ct + 1
CALL centre(23, blanc, SPACE$(80))
END IF

END SELECT
END IF
LOOP

SELECT CASE boucle

CASE 1

p$ = LTRIM$(STR$(res&(boucle))) + MID$(p$, 4)

CASE 2

p$ = MID$(p$, 1, INSTR(1, p$, signe$) + 1) + LTRIM$(STR$(res&(boucle)))
IF limit = 2 THEN
p$ = p$ + " = ..."
ELSEIF limit = 3 THEN
p$ = p$ + " + ... = ..."
ELSE
p$ = p$ + " + ... + ... = ..."
END IF

CASE 3
'addition seulement
s2 = 1: i = 0
DO
s = INSTR(s2, p$, signe$)
s2 = s + 1
i = i + 1
LOOP WHILE i < 2

p$ = MID$(p$, 1, s + 1) + LTRIM$(STR$(res&(boucle)))

IF limit = 3 THEN
p$ = p$ + " = ..."
ELSE
p$ = p$ + " + ... = ..."
END IF

CASE 4
'addition seulement
s2 = 1: i = 0
DO
s = INSTR(s2, p$, signe$)
s2 = s + 1
i = i + 1
LOOP WHILE i < 3

p$ = MID$(p$, 1, s + 1) + LTRIM$(STR$(res&(boucle))) + " = ..."

END SELECT

COLOR , bleu
FOR v = 14 TO 18
CALL centre(v, 0, SPACE$(80))
NEXT
COLOR , noir
h = INT(41 - (LEN(p$) + 4) / 2)
CALL cadre(14, h, LEN(p$) + 2, 4, rouge%)
COLOR , rouge%
CALL centre(16, jaune%, p$)

NEXT boucle '***************************

'résultats pour les données :
IF ct = 0 THEN
re = re + 2
ELSEIF ct = 1 THEN
re = re + 1
END IF
ct = 0

COLOR , bleu
CALL centre(12, 0, SPACE$(80))
flag = 0: GOSUB affichetexte
'on déplace le cadre vers la gauche
CALL attendre(1)
FOR v = 14 TO 18
CALL centre(v, 0, SPACE$(80))
NEXT
COLOR , noir
CALL cadre(14, 10, LEN(p$) + 2, 4, rouge%)
COLOR blancbrill, rouge
LOCATE 16, 12: PRINT p$
COLOR , bleu

ct = 0
'saisir l'opération //////////////////////////
FOR i = 1 TO limit
nombre&(i) = res&(i)
NEXT

COLOR vertclair

SELECT CASE VAL(op$)
CASE 1
IF limit = 4 THEN v = 13 ELSE v = 14
h = 60
LOCATE v - 2, 50: PRINT "Effectue l'opération"
CALL add(reponse$, nombre&(), limit, ct%, v, h, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, bleu)

CASE 2
v = 14: h = 60
LOCATE v - 2, 50: PRINT "Effectue l'opération"
CALL soust(reponse$, nombre&(1), nombre&(2), ct%, v, h, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, bleu)

CASE 3
'inverser les nombres si numérateur < numérande
IF nombre&(1) < nombre&(2) THEN SWAP nombre&(1), nombre&(2)
v = 13: h = 60
LOCATE v - 2, 50: PRINT "Effectue l'opération"
CALL multi(reponse$, nombre&(1), nombre&(2), ct%, v, h, 5, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, bleu)

CASE 4
v = 13: h = 60
LOCATE v - 2, 50: PRINT "Effectue l'opération"
CALL divi(reponse$, nombre&(1), nombre&(2), ct%, v, h, i%, j%, noir%, bleu%, vert%, rouge%, marron%, blanc%, vertclair%, cyanclair%, rougeclair%, jaune%, blancbrill%, bleu)
END SELECT

reponse$ = LTRIM$(STR$(VAL(reponse$)))

'résultat pour opération :
IF ct = 0 THEN
re = re + 3
ELSEIF ct = 1 THEN
re = re + 2
ELSEIF ct = 2 THEN
re = re + 1
END IF
ct = 0

CALL attendre(1.5)
MouseShow

COLOR , bleu
FOR v = 11 TO 20
LOCATE v: PRINT SPACE$(80)
NEXT
p$ = MID$(p$, 1, LEN(p$) - 3) + reponse$ + " ......"
COLOR , noir
CALL cadre(14, 10, LEN(p$) + 2, 4, rouge%)
COLOR blancbrill, rouge
LOCATE 16, 12: PRINT p$
COLOR , bleu

'choisir l'unité
FOR i = 1 TO 4
un$(i) = uni$(i, pb)
NEXT

DO
v = 15: h = 56
COLOR vertclair, bleu
LOCATE v - 2, h - 4: PRINT "Choisis l'unité"
CALL fleches(v, h, un$(), 4, r, bleu, 0, 23, 35)
COLOR , noir
CALL centre(23, 7, SPACE$(80))

IF r = soluni(pb) THEN
CALL exact2
IF ct = 0 THEN re = re + 2
ct = 0
EXIT DO
ELSE
ct = ct + 1
IF ct < 3 THEN
CALL erreur2
ELSE
CALL solution(un$(soluni(pb)))
CALL attendre(2)
CALL centre(23, 0, SPACE$(80))
END IF
END IF
LOOP

p$ = MID$(p$, 1, LEN(p$) - 6) + un$(soluni(pb))
COLOR , bleu
FOR v = 12 TO 20
LOCATE v: PRINT SPACE$(80)
NEXT
CALL centre(12, jaune, quest$(pb))
COLOR , noir
h = INT(41 - (LEN(p$) + 4) / 2)
CALL cadre(14, h, LEN(p$) + 2, 4, rouge)
COLOR , rouge
CALL centre(16, jaune, p$)

CALL entree(noir, noir)

NEXT ii '+++++++++++++++++++++++++++++

IF vertclair = 7 THEN vertclair = 15

re = INT(re / ope): IF re < 0 THEN re = 0

'résultats
CALL resultats(re, ni, 3)

EXIT SUB

affichetexte:
kk = 1: l2 = 0
LOCATE 7, , 0
'affichage du texte
DO
l = LEN(m$(kk))
l2 = l2 + l

IF kk = flag THEN
IF couleur = 1 THEN
COLOR bleu, blanc
ELSE
COLOR noir, blanc
END IF
END IF

IF l2 > 80 THEN
PRINT : kk = kk - 1: l2 = 0
ELSEIF l2 = 80 THEN
PRINT m$(kk); : l2 = 0
ELSEIF l2 = 80 - 1 THEN
PRINT m$(kk): l2 = 0
ELSE
PRINT m$(kk);
IF couleur = 1 THEN
COLOR blancbrill, bleu
ELSE
COLOR blanc, noir
END IF
PRINT " "; : l2 = l2 + 1
END IF

IF couleur = 1 THEN
COLOR blancbrill, bleu
ELSE
COLOR blanc, noir
END IF
kk = kk + 1
LOOP WHILE kk <= nm
PRINT
RETURN
END SUB
 

 

Précédente Accueil Remonter Suivante