intro algo (PDF)




File information


This PDF 1.5 document has been generated by Microsoft® Word 2016, and has been sent on pdf-archive.com on 06/12/2015 at 16:25, from IP address 77.84.x.x. The current document download page has been viewed 427 times.
File size: 1.85 MB (16 pages).
Privacy: public file
















File preview

































algo nomAlgo
/* déclaration des variables et des constantes */
/* instructions à suivre pour résoudre le problème */
fin




Algo nomAlgo
Variables

nomVar1 : type1
nomVar2, nomVar3 : type2

fin














ˋ

ˋ

ˋ






nomVar1 <- valeur
nomVar2 <- expression
debut
i <- 3
a <- i + 1

/* a = 4 */

fin

constante nomCste = valeurCste

lire(nomVar) :




écrire(“le résultat est : ”, nomVar)

Cette instruction affiche à l’écran le texte entre “ ” suivi de la valeur contenue





si (condition)
alors séquenceInstructions1
fsi
si (condition)
alors sequenceInstructions1
sinon sequenceInstructions2
fsi






Algo valeurAbsolue
variable A, absA : entier
debut
ecrire (« donner une valeur »)
lire(A)
si (A > 0)
alors absA <- A
sinon absA <- A x (-1)
fsi
ecrire(absA)

fin










pour variableCompteur de valeurDebut à valeurFin [pas valeurPas] faire
sequenceInstructions
fpour





Algo Somme
variable n, i, som : entier
debut
pour i de 1 à n, faire
som <- som + i
fpour
ecrire(som)
fin

tant que (condition), faire
instructions
ftq




Algo somme
variables n, som : entiers
debut
ecrire(« entrer n »)
lire(n)
som <- 0
i <- 1
tant que (i =< n) , faire
som <- som + i
i <- i + 1
ftq
ecrire(som)
fin

repeter
sequenceInstructions
Tant que (condition)

Algo somme
variables n, som : entiers
debut
ecrire(« entrer n »)
lire(n)
som <- 0
i <- 1
repeter
som <- som + i
i <- i + 1
tant que (i =< n)
ecrire(som)
fin

sousProgramme nomDuSousProgramme (parametres)
declaration des variables locales
debut
sequence instructions
fin








procedure nomProcedure(parametres)
declaration des variables locales
debut
sequences instructions
fin
(parametres) <=> ()
(DON = par1 : type1, ...;
RES = parn : typen, ...;
DONRES = parp : typep, ...;)

DON : som
RES : nb5, nb2, nb1
DONRES :
procedure decomposition(DON = som : entier; RES = nb5, nb2, nb1 : entier)
variable reste : entier
debut
nb5 <- som div 5
reste <- som mod 5
nb2 <- reste div 2
nb1 <- reste mod 2
fin
algo appelProcedure
variables montant : entier nb5, nbP2, nbP1 : entier
debut
ecrire("Donner montant")
lire(montant)
decomposition(montant, nb5, nbP1, nbP2)
ecrire(nb5, "billets de 5€, ", nbP2, "..."")
fin









fonction nomFonction (parametres) : typeDuRésultat
declaration des variables locales
debut
sequence instructions
retourner(valeurRetourneeParLaFonction)
fin

(DON : x, n)

(RES : puissance)

(DONRES : )

fonction puissance(DON = x, n : entier) : entier
variable i, res : entier
debut
res <- 1
pour i allant de 1 à n, faire
res <- res X x
finPour
retourner(res)
fin
algo appelFonction
variables x, n, puiss : entier
debut
ecrire("Donner x et n")
lire(x)
lire(n)
puiss <- puissance(x, n)
ecrire(puiss)
fin













nomVar : tableau[nombreElementsMax] de typeDesElements

nomVar : tableau[nombreElementsLigne, nombreElementsMaxColonne] de typeDesElements




nomVar[indice]
: nomVar[indiceLigne, indiceColonne]

pour i de 0 à nbE-1 faire
/* traitement sur tab[i] */
fpour

pour i de 0 à nbEL-1, faire
pour i de 0 à nbEC-1, faire
/* traitement sur tab[i] */
fpour
fpour



procédure ajout( DON = val: entier,
DONRES = tab, tableau[tailleMax] d'entiers, nbE: entier)
début
si (nbE < tailleMax), alors
tab[nbE] <- val
nbE <- nbE + 1
fsi
fin





DON = p DONRES = nbE, tab
RES =
procedure supprimer (
DON = p ;
DONRES = tab : tableau [tailleMax] d’entiers, nbE : entier)
debut
si (p >= 0) et (p < nbE)
alors
tab[p] <-- tab[nbE-1]
nbE <-- nbE-1
fsi
fin







DON = nbE, tab DONRES =RES = min
fonction min(DON = nbE :entier, tab :tableau[tailleMax] d’entiers) :entier
variable min, i :entier
debut
min <-- tab[0]
pour i de 1 à nbE-1, faire
si(tab[i] < min)
alors min <-- tab[1]
fsi
fpour
retourner(min)
fin







DON = val, tab, nbE
DONRES =
RES = rep
fonction appartient(DON = tab :tableau[tailleMax] d’entiers, nbE : entier, val :entier) :booléen
variable i : entier ; trouve : booléen
debut
trouve <-- faux
tant que non(trouve) et (i < nbE), faire
si val = tab[i]
alors trouve <-- vrai
sinon i <-- i + 1
fsi
ftq
retourner(trouve)
fin

debut
i <-- 0
tant que(i < nbE) et (val != tab[i]), faire
i <-- i + 1
ftq
si (i < nbE)
alors retourner(vrai)
sinon retourner(faux)
fsi
fin


o
o


DON = val
DONRES = nbE, tab
RES =
procedure ajout( DON = val:entier
DONRES = nbE:entier; tab:tableau[tailleMax] d’entiers)
varibales i:entier
debut
si(nbE < tailleMax)
alors i <- nbE – 1
tant que (i >= 0) et (val < tab[i])
tab[i + 1] <- tab[i]
i <- i – 1
ftq
tab[i + 1] <- val
nbE <- nbE + 1
fsi
fin



DON = p DONRES = nbE, tab
procedure suppression(

RES =

DON = p:entier
DONRES = nbE:entier; tab:tableau[tailleMax] d’entier)

debut
si (p >= 0) et (p < nbE)
alors
pour i de p à nbE – 2, faire
tab[i] <- tab[i + 1]
fpour
fsi
fin



o
o
o




fonction appartient(DON = val:entier; tab:tableau[tailleMax] d’entier; nbE: entier):booleen
varibale
i:entier
trouve:booleen
debut
i <- 0
trouve <- faux
tant que (i < nbE) et (non(trouve)), faire
si (tab[i] >= val)
alors trouve <- vrai
sinon i <- i + 1
fsi
ftq
fin









fonction rechercheDicho(DON = val:entier; tab:tableau[tailleMax]d’entier; nbE:entier):booleen
variable
deb, milieu:entier
trouve:booleen
debut
deb <- 0
fin <- nbE – 1
trouve <- faux
tant que (deb <= fin) et (non(trouve))
milieu <- (deb + fin) div 2
si (tab[milieu] = val)
alors trouve <- vrai
sinon
si (tab[milieu] > val)
alors fin <- milieu – 1
sinon
fsi
fsi
ftq
retourner(trouve)
fin






Download intro algo



intro algo.pdf (PDF, 1.85 MB)


Download PDF







Share this file on social networks



     





Link to this page



Permanent link

Use the permanent link to the download page to share your document on Facebook, Twitter, LinkedIn, or directly with a contact by e-Mail, Messenger, Whatsapp, Line..




Short link

Use the short link to share your document on Twitter or by text message (SMS)




HTML Code

Copy the following HTML code to share your document on a Website or Blog




QR Code to this page


QR Code link to PDF file intro algo.pdf






This file has been shared publicly by a user of PDF Archive.
Document ID: 0000319700.
Report illicit content