1 / 17

Informatique Cours 8 5/11/2001

Informatique Cours 8 5/11/2001. Algorithmique et programmation. Fonctions et procédures Les nombres Minimum - maximum Régression linéaire Nombres premiers Les caractères. LDA (rappel). Déclaratives Tableau Type w = tableau 1..5, 8..17 de réels Variable

rianna
Download Presentation

Informatique Cours 8 5/11/2001

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. InformatiqueCours 8 5/11/2001 Algorithmique et programmation

  2. Fonctions et procédures • Les nombres • Minimum - maximum • Régression linéaire • Nombres premiers • Les caractères

  3. LDA (rappel) • Déclaratives • Tableau Type w = tableau 1..5, 8..17 de réels Variable donnees : w • Fichier Type t = texte Variable f : t

  4. LDA (rappel) • Fonctions • Procédures • En-tête • Déclaratives • Corps • Exécutables • Fin La fonction prend une VALEUR

  5. LDA (suite) • PARAMETRES dans l ’en-tête entrants (par valeur) entrants-sortants (par adresse) sortants (adresse)

  6. Nombres (suite) • Procédures • Minmax Recherche du minimum et du maximum • Régresproc Régression linéaire • Erato Recherche de nombres premiers

  7. Nombres minimum-maximum Bloc minimum_maximum Constante N=200 Type v = vecteur 1..N de réels Variables z: v ; minz, maxz: réels imin, imax: entiers Corps lire(z) minmax(z, minz, maxz, imin, imax) écrire(minz, ‘  en ‘ , imin) écrire(maxz, ‘  en ‘ , imax) Fin bloc

  8. Nombres minimum-maximum Procédure minmax ( nombres: v ; min, max: réels ; posmin, posmax: entiers ) Variable k:entier Corps posmin <-- 1 ; posmax <-- 1 min <-- nombre1 ; max <-- nombre1 pour k de 2 à N faire si nombrek < min alors min <-- nombrek ; posmin <-- k sinon si nombrek > max alors max <-- nombrek; posmax <-- k fin si fin pour Fin procédure

  9. Nombres régression

  10. Nombres régression Bloc regres Constante N=200 Type v = vecteur 1..N de réels Variables x, y: v a,b: réels Corps lire(z) regresproc(x, y, a,b) écrire(‘  valeur de a ‘ , a) écrire(‘  valeur de b ‘, b) Fin bloc

  11. Nombres régression Procédure regresprog ( x,y: v ; a, b: réels ) Variable k:entier sx, sx2, sy, sxy: réels Corps sx <-- 0 ; sx2 <-- 0 ; sy <-- 0 ; sxy <-- 0 pour k de 1 à N faire sx <-- sx + xk ; sx2 <-- sx2 + xk*xk sy <-- sy + yk ; sxy <-- sxy + xk*yk fin pour a <-- (sy*sx2 - sxy*sx) / (n*sx2 - sx*sx) b <-- (n*sxy - sy*sx) / (n*sx2 - sx*sx) Fin procédure

  12. Nombres régression Procédure regresprog ( x,y: v ; a, b: réels ) Variable k:entier; sx, sx2, sy, sxy: réels; Corps sx <-- somme(x) ; sx2 <-- scalaire(x,x) sy <-- somme(y) ; sxy <-- scalaire(x,y) fin pour a <-- (sy*sx2 - sxy*sx) / (n*sx2 - sx*sx) b <-- (n*sxy - sy*sx) / (n*sx2 - sx*sx) Fin procédure

  13. Nombres somme Fonction somme (x :v):réelle Variables k:entier s:réel Corps s <-- 0.0 pour k de 1 à n faire s <--s + xk fpour somme <--s Fin fonction

  14. Nombres produit scalaire Fonction scalaire (x, y:v):réelle Variables k:entier s:réel Corps s <-- 0.0 pour k de 1 à n faire s <--s + xk * yk fpour scalaire <--s Fin fonction

  15. Nombres nombres premiers Bloc premiers Constante N = 200 Type v = vecteur 1..N de booléens Variables premiers: v ; k: entier Corps eratosthene (premiers) pour k de 1 à N faire si premiersk alors écrire(k) fin si fpour fbloc

  16. Nombres nombres premiers Procédure eratosthene ( premier: v ) Variable j,k: entiers; Corps premier <-- vrai ; k <-- 2 tant que k ≤ sqrt(N) faire tant que NON premierk et k < sqrt(N) faire k <-- k + 1 ftant pour j de 2 à N ÷ k faire premier j * k <-- faux fpour k <-- k + 1 ftant Fin procédure

  17. Les caractères • Ensemble ordonné • Codage ASCII ( 7 bits: 27 = 128 codes ) American Standard Code for Information Interchange ASCII étendu ( 8 bits ) ISO latin-1 UNICODE ( 2 octets ) • Table de collationnement

More Related