no save
Assistance
Achat
News

Forum | programmation
algorithme du ppmc
p.legal, le mar. 05 juil. 2005 à 13:33:13
Et UN calcul de PGCD par ici :
print "calcul du plus grand commun diviseur"
input "combien de nombres voulez-vous comparer ";nb
dim n(nb)
maxi=0
for i=1 to nb
print "entrez le nombre numero ";i
input n(i)
next i
cls
print "je recherche le pgcd de ces nombres..."
sort n(, nb, 1
for i=1 to nb
print n(i)
next i
nb1=n(1)
nb2=n(2)
gosub [pgcd]
if nb>2 then
for u=3 to nb
nb1=pgcd
nb2=n(u)
gosub [pgcd]
next u
end if
print "le pgcd est :"
print pgcd
input r$
end

[pgcd]
mini=min(nb1, nb2)
maxi=max(nb1, nb2)
ecart=maxi-mini
if nb1*nb2=0 then
pgcd=maxi
goto [end.pgcd]
end if

while ecart<>0
scan
maxi=max(ecart,mini)
mini=min(ecart,mini)
ecart=maxi-mini
wend
pgcd=maxi
[end.pgcd]
return

@++

liberty BASIC France: http://lbasic.atomysk.com
Forum d'aide : http://lbasic.tatomysk.com/forum
Précédentus
juil. 05
nono78 pro genius
déc. 07
Suivant
REPONSES
PASCAL
févr. 05
pascal
févr. 05
pascal
févr. 05
stephane
févr. 05
pascal
févr. 05
us
juil. 05
p.legal
juil. 05
nono78 pro genius
déc. 07
arnaud genius 78700
déc. 07
Version Web
Réalisé par RedShift
no save